PHPackages                             coduo/tutu - 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. coduo/tutu

ActiveProject

coduo/tutu
==========

TuTu - simple HTTP server mocking tool in PHP.

1.0.1(9y ago)5812.7k10[3 issues](https://github.com/coduo/TuTu/issues)4MITPHPPHP &gt;=5.5.0

Since Nov 20Pushed 9y ago6 watchersCompare

[ Source](https://github.com/coduo/TuTu)[ Packagist](https://packagist.org/packages/coduo/tutu)[ RSS](/packages/coduo-tutu/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (16)Versions (4)Used By (4)

\#TuTu

[![Build Status](https://camo.githubusercontent.com/f3d9296d4d44af58080c7499d56e4f3d7e6299c8effd7f69ef5e28d4ae3b46f3/68747470733a2f2f7472617669732d63692e6f72672f636f64756f2f547554752e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/coduo/TuTu)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/16fb73da2fd7288f6ab0a8af168d179432e05268a75df00a34874c32e37fa415/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f64756f2f547554752f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/coduo/TuTu/?branch=master)

Flexible HTTP server mocking tool in PHP. TuTu can work with build in php server so everything that you need to use it is php. It can be used to simulate any kind of web application behavior. We are going to use TuTu during api clients tests.

How to use it
-------------

[](#how-to-use-it)

### Install with composer

[](#install-with-composer)

```
$ composer create-project coduo/tutu --stability=dev

```

**TuTu is still under development that's why you need to set stability to dev**

### Create responses for specific requests

[](#create-responses-for-specific-requests)

TuTu can create any response for specific request but you need to teach him how to do it. In order to do that you need to prepare simple `responses.yml` yaml file.

```
$ cd tutu
$ cp config/responses.yml.dist config/responses.yml

```

Lets assume that we would like to create some kind of "Hello world" response

```
hello_world:
  request:
    path: /hello/world
    methods: ['GET']
  response:
    content: |
      Hello {{ request.query.get('name') }}!

```

### Run TuTu

[](#run-tutu)

You can use php build in webserver to run TuTu

```
$ cd web
$ php -S localhost:8000

```

### Test TuTu

[](#test-tutu)

How when you send a GET request on "" TuTu should give you response with following content

`Hello Norbert!`

Responses configuration
-----------------------

[](#responses-configuration)

```
# config/responses.yml

hello_world_get:
  request:
    path: /hello/world
    methods: ['GET']
    query: []
    request: []
    headers: []
    body: ""
  response:
    content: "This is nothing more than twig template"
    status: 200
    headers:
      "Content-type": "application/json"

```

As you can see there are few was to customize TuTu responses.

- `request.path` - required option, it represents route. You can use placeholders to create route, for example `/hello/{name}`
- `request.methods` - optional. When empty any method is allowed. Must be a valid array
- `request.request` - optional. When not empty it will match only request that contain body ($\_POST) parameters.
- `request.query` - optional. When not empty it will match only request that contain query ($\_GET) parameters.
- `request.headers` - optional. When not empty it will match only request that contain specified headers.
- `request.body` - optional. When not empty it will match only request that contain specified body.
- `response.content` - optional. Content is nothing more that twig template rendered before passed to response.
- `response.status` - optional. Response code
- `response.headers` - optional. Headers added to response Must be a valid array

In content template you have access to all twig features. You can also use `request` variable to access request data.

**Request query, headers, request and body configuration may contain [coduo/php-matcher patterns](https://github.com/coduo/php-matcher#available-patterns).**

Load response content from file
-------------------------------

[](#load-response-content-from-file)

In order to keep your config files as small as possible you can move response content into separated file.

```
# config/responses.yml

hello_world_get:
  request:
    path: /hello/world
    methods: ['GET']
  response:
    content: @resources/hello_world.twig.html

```

Above configuration is going to load content from hello\_world.twig.html file present in `@resources` namespace.

```
{# resources/hello_world.twig.html #}
Hello {{ request.request.get('name') }}!

```

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

[](#configuration)

TuTu have also configuration file where you can set up few things.

```
# config/config.yml
parameters:
  resources_path: '/var/www/tutu/custom_resources' # empty by default
  responses_file_path: '/var/www/tutu/config/custom_responses.yml' # empty by default
  twig: # optional, must be a valid array. Passed to twig env
    debug: true
    auto_reload: true

extensions:
  Coduo\TuTu\Extension\Faker: ~

```

Extensions
----------

[](#extensions)

Because there is no such thing as perfect tool TuTu allows you to create extensions. To enable extension you just need to prepare `config.yml` file.

```
# config/config.yml
extensions:
    Coduo\TuTu\Extension\Faker: ~
```

Above example show how to load Faker extension (available in this repository). You can also pass arguments to extension during initialization.

```
# config/config.yml
extensions:
    Coduo\TuTu\Extension\Faker:
        - "pl_PL"
```

In above example extension `Coduo\TuTu\Extension\Faker` is going to be created with one argument with value "pl\_PL".

**Keep in mind that Faker extension is available in TuTu by default. You don't need to enable it manually.**

Few Examples
------------

[](#few-examples)

```
# config/responses.yml

client_token_grant:
  request:
    path: "/oauth/v2/token"
    query:
      "client_id": "CLIENT_VALID_ID"
      "client_secret": "CLIENT_VALID_SECRET"
      "grant_type": "client_credentials"
  response:
    content: "@resources/oauth2/client_token_grant.json.twig"
    headers:
      Content-Type: application/json

missing_grant_type:
  request:
    path: "/oauth/v2/token"
  response:
    content: "@resources/oauth2/missing_grant_type.json.twig"
    status: 400
    headers:
      Content-Type: "application/json"

register_customer:
  request:
    path: "/api/customer"
    methods: ['POST']
    headers:
      Authorization: "Bearer VALID_CLIENT_ACCESS_TOKEN"
    body: |
      {
        "email": @string@,
        "plainPassword": @string@,
        "firstName": @string@,
        "lastName": @string@
      }
  response:
    content: "@resources/api/customer/register_customer.json.twig"
    headers:
      Content-Type: application/json

register_with_missing_parameters:
  request:
    path: "/api/customer"
    methods: ['POST']
    headers:
      Authorization: "Bearer VALID_CLIENT_ACCESS_TOKEN"
  response:
    content: "@resources/api/customer/register_missing_parameters.json.twig"
    status: 422
    headers:
      Content-Type: application/json

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 81.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

3464d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/52325810?v=4)[norbert-tech](/maintainers/norbert-tech)[@norbert-tech](https://github.com/norbert-tech)

---

Top Contributors

[![norberttech](https://avatars.githubusercontent.com/u/1921950?v=4)](https://github.com/norberttech "norberttech (67 commits)")[![defrag](https://avatars.githubusercontent.com/u/15900?v=4)](https://github.com/defrag "defrag (10 commits)")[![drymek](https://avatars.githubusercontent.com/u/492240?v=4)](https://github.com/drymek "drymek (1 commits)")[![szyku-tsh](https://avatars.githubusercontent.com/u/18327178?v=4)](https://github.com/szyku-tsh "szyku-tsh (1 commits)")[![tomasz-kolodziej-esky](https://avatars.githubusercontent.com/u/137406885?v=4)](https://github.com/tomasz-kolodziej-esky "tomasz-kolodziej-esky (1 commits)")[![llubosz](https://avatars.githubusercontent.com/u/2283771?v=4)](https://github.com/llubosz "llubosz (1 commits)")[![dominikjaglo](https://avatars.githubusercontent.com/u/3235011?v=4)](https://github.com/dominikjaglo "dominikjaglo (1 commits)")

###  Code Quality

TestsBehat

### Embed Badge

![Health badge](/badges/coduo-tutu/health.svg)

```
[![Health](https://phpackages.com/badges/coduo-tutu/health.svg)](https://phpackages.com/packages/coduo-tutu)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
