Download the PHP package pbxapi/php-http-fixture-client without Composer

On this page you can find all versions of the php package pbxapi/php-http-fixture-client. 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 php-http-fixture-client

Fixture client for PHP-HTTP

PHP from Packagist Latest Version on Packagist Software License Build Status Scrutinizer Coverage Scrutinizer Code Quality Made by SWIS

This is a fixture client for PHP-HTTP and is meant for testing purposes. It maps requests to static fixtures.

Install

Usage

Fixture mapping

All requests send using this client are mapped to static fixtures located in the provided path. URLs are transformed to file paths by using the domain and path fragments and (optionally) the method and/or the query params (sorted alphabetically). A list of possible fixture paths is made and handled in order of specificity:

  1. {path}.{query}.{method}.mock
  2. {path}.{query}.mock
  3. {path}.{method}.mock
  4. {path}.mock

Please see the following table for some examples.

URL Method Possible fixtures (in order of specificity)
http://example.com/api/articles/1 GET /path/to/fixtures/example.com/api/articles/1.get.mock
/path/to/fixtures/example.com/api/articles/1.mock
http://example.com/api/articles POST /path/to/fixtures/example.com/api/articles.post.mock
/path/to/fixtures/example.com/api/articles.mock
http://example.com/api/comments?query=json GET /path/to/fixtures/example.com/api/comments.query=json.get.mock
/path/to/fixtures/example.com/api/comments.query=json.mock
/path/to/fixtures/example.com/api/comments.get.mock
/path/to/fixtures/example.com/api/comments.mock
http://example.com/api/comments?query=json&order=id GET /path/to/fixtures/example.com/api/comments.order=id&query=json.get.mock
/path/to/fixtures/example.com/api/comments.order=id&query=json.mock
/path/to/fixtures/example.com/api/comments.get.mock
/path/to/fixtures/example.com/api/comments.mock

Strict mode

The ReponseBuilder can be set to strict mode using setStrictMode(true). When in strict mode, only the first possible fixture path will be used. This means that both the method and query params must be present in the fixture file name and it does not fall back to other fixture files.

Helper

Please see https://swisnl.github.io/php-http-fixture-client/#helper for the URL helper.

Body

The body of a request is loaded directly from a fixture with the file extension .mock. The contents of this file can be anything that is a valid HTTP response, e.g. HTML, JSON or even images. If a fixture can not be found, a MockNotFoundException will be thrown. This exception has a convenience method getPossiblePaths() which lists all file paths that were checked, in order of specificity.

Headers (optional)

The headers of a request are loaded from a fixture with the file extension .headers. This is a simple JSON object with headers, e.g.

Status (optional)

The status code of a request is loaded from a fixture with the file extension .status. This is a plain file containing only the HTTP status code. If no .status file is found, 200 OK will be used.

Mocks (advanced)

This client extends php-http/mock-client, which allows you to add custom responses and exceptions that ignore fixture files. Please see the mock-client documentation for more information.

N.B. A default response can not be set because this client uses that under the hood.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

SWIS

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.


All versions of php-http-fixture-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
danielstjules/stringy Version ^3.1
php-http/discovery Version ^1.4
php-http/mock-client Version ^1.2
psr/http-message Version ^1.0
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 pbxapi/php-http-fixture-client contains the following files

Loading the files please wait ....