Download the PHP package shiishiji/wiremock-php without Composer

On this page you can find all versions of the php package shiishiji/wiremock-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wiremock-php

wiremock-php Build Status

Stub and mock web services with the power of WireMock from PHP.

WireMock provides a JSON API for interacting with it; wiremock-php makes it easy to use that JSON API from PHP by wrapping it up in a fluent API very similar to the Java API provided by WireMock.

Note that wiremock-php requires a standalone instance of WireMock to be run (which requires Java).

Version numbers track those of WireMock itself, but may lag behind (i.e. if a WireMock release does not contain changes to the API, there may be no corresponding version of wiremock-php).

Alternatives

Like the idea of stubbing & verifying HTTP requests, but don't like this library (maybe you don't want to install Java)? You might want to investigate the following:

Installation

It's easiest to install wiremock-php via Composer:

Usage

API

The API is based directly on WireMock's Java API, so see the WireMock documentation for general help with interacting with WireMock.

Differences to Java API

To provide a fluent interface, the WireMock Java API makes use of statically imported methods (which act upon a default static instance), but it's also possible to act directly upon a Java WireMock instance (using slightly differently named methods).

Prior to version 5.6 (back when wiremock-php was created), PHP didn't support anything like Java's static import of methods. Instead, in wiremock-php some methods which are static in Java are instance methods. Those methods are:

Also, the Java API has methods (ResponseDefinitionBuilder::withBody and WebhookDefinition::withBinaryBody) that take a byte array. Byte arrays are less common in PHP, so instead, withBodyData methods are provided, which takes a string to be base64 encoded. To produce an appropriate string from an array of bytes, use pack.

The date and time request matcher functions (before, beforeNow, equalToDateTime, isNow, after, afterNow) can be used with offsets (expectedOffset($amount, $unit)). In the Java API, the unit parameter is an enum; in wiremock-php these values are consts on DateTimeMatchingStrategy. Similarly, truncation types (for use with truncateExpected and truncateActual) are enums in the Java API, but are consts on DateTimeMatchingStrategy in wiremock-php.

The stubImport method is static on StubBuilder in Java. In WireMock, to keep all the public static methods in one predictable place, this method is available as WireMock::stubImport.

The request method constants are available on WireMock\Http\RequestMethod;

In addition, wiremock-php adds the instance method isAlive. This polls the standalone WireMock instance until an OK response is received or a timeout is reached, allowing your PHP code to wait until WireMock is ready.

Example

A typical usage looks something like the following:

Verification PHPUnit integration

If a verification fails a VerificationException is thrown. If PHPUnit is present on the include path, this will be a subclass of PHPUnit_Framework_AssertionFailedError, thus causing any containing PHPUnit test to fail; if PHPUnit is not present, VerificationException subclasses Exception.


All versions of wiremock-php with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
ext-curl Version *
php Version >=8.0
symfony/serializer Version ^5.4
symfony/property-access Version ^5.4
symfony/property-info Version ^5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shiishiji/wiremock-php contains the following files

Loading the files please wait ....