PHPackages                             darkmatus/phiremock-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. darkmatus/phiremock-server

ActiveProject[Testing &amp; Quality](/categories/testing)

darkmatus/phiremock-server
==========================

A mocker for HTTP and REST services

v2.0.6(4y ago)01.2k1GPL-3.0-or-laterPHPPHP ^8

Since Apr 13Pushed 4y agoCompare

[ Source](https://github.com/darkmatus/phiremock-server)[ Packagist](https://packagist.org/packages/darkmatus/phiremock-server)[ RSS](/packages/darkmatus-phiremock-server/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (13)Versions (15)Used By (1)

Phiremock Server
================

[](#phiremock-server)

Phiremock is a mocker and stubber of HTTP services, it allows software developers to mock HTTP requests and setup responses to avoid calling real services during development, and is particulary useful during acceptance testing when expected http requests can be mocked and verified. Any HTTP service (i.e.: REST services) can be mocked and stubbed with Phiremock.

Phiremock is heavily inspired by [WireMock](http://wiremock.org/), but does not force you to have a java installation in your PHP development environment. The full functionality of Phiremock is detailed in the following list:

- Allows to mock http request based in method, headers, url, body content and form fields.
- Allows to match expectations using several comparison functions.
- REST interface to setup.
- Stateful and stateless mocking through scenarios.
- Network latency simulation.
- Priorizable expectations for cases in which more than one matches the request. If more than one expectation matches the request and no priorities were set, the first match is returned.
- Allows to verify the amount of times a request was done.
- Allows to load default expectations from json files in a directory tree.
- Proxy requests to another URL as they are received.
- Fill the response body using data from the request.
- Integration to codeception through [phiremock-codeception-extension](https://github.com/mcustiel/phiremock-codeception-extension) and [phiremock-codeception-module](https://github.com/mcustiel/phiremock-codeception-module).
- Client with nice API supporting all functionalities: [phiremock-client](https://github.com/mcustiel/phiremock-client)

[![Version](https://camo.githubusercontent.com/f926be8400eb1f52050efd73003ed74d154a5e18da44dc8247efa2fed2c21235/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6375737469656c2f70686972656d6f636b2d736572766572)](https://packagist.org/packages/mcustiel/phiremock-server)[![Build Status](https://camo.githubusercontent.com/bb838f0a80718e56b4bd3c122d40aab3869a985eeef58ecd7e9d5929862bf12d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d7365727665722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-server/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a7af52bfdcf36d6f6fe7905d5a0587ea04e54911e3c08f47c8962a7ca5f8f3ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d7365727665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-server/?branch=master)[![Packagist Downloads](https://camo.githubusercontent.com/f40421d7be2d50ddb5dfa399156482aaf87801fa036c1d8147e19fe755d7c873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6375737469656c2f70686972656d6f636b2d736572766572)](https://packagist.org/packages/mcustiel/phiremock-server)

Installation
------------

[](#installation)

### Default installation through composer

[](#default-installation-through-composer)

```
    "require-dev": {
        "mcustiel/phiremock-server": "^1.0",
        "guzzlehttp/guzzle": "^6.0"
    }
```

Phiremock Server requires guzzle client v6 to work. This dependency can be avoided and you can choose any psr18-compatible http client and overwrite Phiremock Server's factory to provide it.

### Phar

[](#phar)

You can also download the standalone server as a phar from [here](https://github.com/mcustiel/phiremock-server/releases/download/v1.1.2/phiremock.phar).

Running
-------

[](#running)

Execute `./vendor/bin/phiremock`.

### Command line arguments

[](#command-line-arguments)

- **--ip|-i**  - Network interface where to listen for http connections. Default: 0.0.0.0
- **--port|-p**  - Port where to listen for http connections. Default: 8086
- **--expectations-dir|-e**  - Directory where to search for predefined static expectations. Default: \[HOME\_PATH\]/.phiremock/expectations
- **--factory-class|f**  - Factory class to use to create the objects needed by phiremock server. Default: Default internal factory class.
- **--certificate|t**  - Certificate file to enable phiremock to listen for secure connections (https).
- **--certificate-key|k**  - Path to the certificate key.
- **--cert-passphrase|s**  - Passphrase to use if the certificate is encrypted.
- **--debug|-d** - Flag to activate the debug mode.

**Note:** Static expectations saved in files are very useful if you use phiremock in your development environment. For testing, can be more useful to setup expectations on the fly.

**Note:** When a certificate is added, phiremock-server will only listen for secure connections.

Configuration
-------------

[](#configuration)

You can statically specify phiremock server's configuration in the .phiremock file. It looks as following:

```
