/wiremock-bundle

A Symfony bundle to quickly mock Http Clients using Wiremock.

Primary LanguagePHPMIT LicenseMIT

wiremock bundle badge badge maintainability contributions welcome brightgreen license MIT blue
PHP 8 PHP 8 PHP 8 PHP 8
Symfony 5%2B black Symfony 6%2B black Symfony 7%2B black

A Symfony bundle to quickly mock Http Clients using Wiremock. The way it works is by decorating the Symfony HttpClient. It checks if Wiremock has a stub for the request and if it does, it returns the stubbed response. If not, it forwards the request to the original http client as usual.

Table of content

1. Installation

Execute the composer command to install the bundle:

composer require nicolasguilloux/wiremock-bundle --dev

2. Documentation

2.1. Configuration

Here is an example of a configuration with the Wiremock http client:

framework:
    http_client:
        scoped_clients:
            wiremock.client:
                base_uri: 'http://localhost:8080'

wiremock:
    # Set the Wiremock http client (default: wiremock.client)
    # http_client: 'wiremock.client'

    # Removes the Wiremock http client from the HttpClient profiler page (default: false)
    # remove_from_http_client_profiler: true

    # Decorates by default all clients except the following ones (default: [])
    # blacklist_clients: []

    # Decorates only the following http client (default: [])
    # whitelist_clients: []

2.2. Profiler

A new tab is available in the Symfony profiler to see the Wiremock http calls. This might be helpful to see if a request has been used to stub a response or not.

3. Versioning

wiremock-bundle follows semantic versioning. In short the scheme is MAJOR.MINOR.PATCH where 1. MAJOR is bumped when there is a breaking change, 2. MINOR is bumped when a new feature is added in a backward-compatible way, 3. PATCH is bumped when a bug is fixed in a backward-compatible way.

Versions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.

4. Contributing

Contributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:

  • Bug Reports: While we strive for quality software, bugs can happen, and we can’t fix issues we’re not aware of. So please report even if you’re not sure about it or just want to ask a question. If anything the issue might indicate that the documentation can still be improved!

  • Feature Request: You have a use case not covered by the current api? Want to suggest a change or add something? We’d be glad to read about it and start a discussion to try to find the best possible solution.

  • Pull Request: Want to contribute code or documentation? We’d love that! If you need help to get started, GitHub as documentation on pull requests. We use the "fork and pull model" were contributors push changes to their personal fork and then create pull requests to the main repository. Please make your pull requests against the master branch.

As a reminder, all contributors are expected to follow our Code of Conduct.

5. License

wiremock-bundle is distributed under the terms of the MIT license.

See LICENSE for details.

6. Hacking

Nix and devenv are here to help you install the software dependencies.

With the two tools installed, you can simply enter a working shell: devenv shell.