{"id":28411731,"url":"https://github.com/coduo/tutu","last_synced_at":"2025-06-24T07:32:41.454Z","repository":{"id":18402812,"uuid":"21584368","full_name":"coduo/TuTu","owner":"coduo","description":"Flexible HTTP server mocking tool in PHP. TuTu can work with built-in php server so everything that you need to use is php.","archived":false,"fork":false,"pushed_at":"2016-12-05T08:13:20.000Z","size":174,"stargazers_count":58,"open_issues_count":3,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-03T06:10:46.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coduo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-07T19:49:05.000Z","updated_at":"2023-06-01T15:49:20.000Z","dependencies_parsed_at":"2022-09-02T06:44:14.187Z","dependency_job_id":null,"html_url":"https://github.com/coduo/TuTu","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/coduo/TuTu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coduo%2FTuTu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coduo%2FTuTu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coduo%2FTuTu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coduo%2FTuTu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coduo","download_url":"https://codeload.github.com/coduo/TuTu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coduo%2FTuTu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261628444,"owners_count":23186818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-02T18:47:40.715Z","updated_at":"2025-06-24T07:32:41.446Z","avatar_url":"https://github.com/coduo.png","language":"PHP","readme":"#TuTu\n\n[![Build Status](https://travis-ci.org/coduo/TuTu.svg?branch=master)](https://travis-ci.org/coduo/TuTu)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/coduo/TuTu/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/coduo/TuTu/?branch=master)\n\nFlexible HTTP server mocking tool in PHP. TuTu can work with build in php server so everything that you need to use it is php.\nIt can be used to simulate any kind of web application behavior. We are going to use TuTu during api clients tests.\n\n## How to use it\n\n### Install with composer\n\n```\n$ composer create-project coduo/tutu --stability=dev\n```\n\n**TuTu is still under development that's why you need to set stability to dev**\n\n### Create responses for specific requests\n\nTuTu can create any response for specific request but you need to teach him how to do it.\nIn order to do that you need to prepare simple ``responses.yml`` yaml file.\n\n```\n$ cd tutu\n$ cp config/responses.yml.dist config/responses.yml\n```\n\nLets assume that we would like to create some kind of \"Hello world\" response\n\n```\nhello_world:\n  request:\n    path: /hello/world\n    methods: ['GET']\n  response:\n    content: |\n      Hello {{ request.query.get('name') }}!\n```\n\n### Run TuTu\n\nYou can use php build in webserver to run TuTu\n\n```\n$ cd web\n$ php -S localhost:8000\n```\n\n### Test TuTu\n\nHow when you send a GET request on \"http://localhost:8000/hello/world?name=Norbert\" TuTu should give you response\nwith following content\n\n```Hello Norbert!```\n\n## Responses configuration\n\n```\n# config/responses.yml\n\nhello_world_get:\n  request:\n    path: /hello/world\n    methods: ['GET']\n    query: []\n    request: []\n    headers: []\n    body: \"\"\n  response:\n    content: \"This is nothing more than twig template\"\n    status: 200\n    headers:\n      \"Content-type\": \"application/json\"\n```\n\nAs you can see there are few was to customize TuTu responses.\n\n* ``request.path`` - required option, it represents route. You can use placeholders to create route, for example ``/hello/{name}``\n* ``request.methods`` - optional. When empty any method is allowed. Must be a valid array\n* ``request.request`` - optional. When not empty it will match only request that contain body ($_POST) parameters.\n* ``request.query`` - optional. When not empty it will match only request that contain query ($_GET) parameters.\n* ``request.headers`` - optional. When not empty it will match only request that contain specified headers.\n* ``request.body`` - optional. When not empty it will match only request that contain specified body.\n* ``response.content`` - optional. Content is nothing more that twig template rendered before passed to response.\n* ``response.status`` - optional. Response code\n* ``response.headers`` - optional. Headers added to response Must be a valid array\n\nIn content template you have access to all twig features. You can also use ``request`` variable to access request data.\n\n**Request query, headers, request and body configuration may contain [coduo/php-matcher patterns](https://github.com/coduo/php-matcher#available-patterns).**\n\n## Load response content from file\n\nIn order to keep your config files as small as possible you can move response content into separated file.\n\n```\n# config/responses.yml\n\nhello_world_get:\n  request:\n    path: /hello/world\n    methods: ['GET']\n  response:\n    content: @resources/hello_world.twig.html\n```\n\nAbove configuration is going to load content from hello_world.twig.html file present in ``@resources`` namespace.\n\n```\n{# resources/hello_world.twig.html #}\nHello {{ request.request.get('name') }}!\n```\n\n## Configuration\nTuTu have also configuration file where you can set up few things.\n```\n# config/config.yml\nparameters:\n  resources_path: '/var/www/tutu/custom_resources' # empty by default\n  responses_file_path: '/var/www/tutu/config/custom_responses.yml' # empty by default\n  twig: # optional, must be a valid array. Passed to twig env\n    debug: true\n    auto_reload: true\n\nextensions:\n  Coduo\\TuTu\\Extension\\Faker: ~\n```\n\n## Extensions\n\nBecause there is no such thing as perfect tool TuTu allows you to create extensions.\nTo enable extension you just need to prepare ``config.yml`` file.\n\n```yml\n# config/config.yml\nextensions:\n    Coduo\\TuTu\\Extension\\Faker: ~\n```\n\nAbove example show how to load Faker extension (available in this repository).\nYou can also pass arguments to extension during initialization.\n\n```yml\n# config/config.yml\nextensions:\n    Coduo\\TuTu\\Extension\\Faker:\n        - \"pl_PL\"\n```\n\nIn above example extension ``Coduo\\TuTu\\Extension\\Faker`` is going to be created with one argument with value \"pl_PL\".\n\n**Keep in mind that Faker extension is available in TuTu by default. You don't need to enable it manually.**\n\n## Few Examples\n\n\n```\n# config/responses.yml\n\nclient_token_grant:\n  request:\n    path: \"/oauth/v2/token\"\n    query:\n      \"client_id\": \"CLIENT_VALID_ID\"\n      \"client_secret\": \"CLIENT_VALID_SECRET\"\n      \"grant_type\": \"client_credentials\"\n  response:\n    content: \"@resources/oauth2/client_token_grant.json.twig\"\n    headers:\n      Content-Type: application/json\n\nmissing_grant_type:\n  request:\n    path: \"/oauth/v2/token\"\n  response:\n    content: \"@resources/oauth2/missing_grant_type.json.twig\"\n    status: 400\n    headers:\n      Content-Type: \"application/json\"\n\nregister_customer:\n  request:\n    path: \"/api/customer\"\n    methods: ['POST']\n    headers:\n      Authorization: \"Bearer VALID_CLIENT_ACCESS_TOKEN\"\n    body: |\n      {\n        \"email\": @string@,\n        \"plainPassword\": @string@,\n        \"firstName\": @string@,\n        \"lastName\": @string@\n      }\n  response:\n    content: \"@resources/api/customer/register_customer.json.twig\"\n    headers:\n      Content-Type: application/json\n\nregister_with_missing_parameters:\n  request:\n    path: \"/api/customer\"\n    methods: ['POST']\n    headers:\n      Authorization: \"Bearer VALID_CLIENT_ACCESS_TOKEN\"\n  response:\n    content: \"@resources/api/customer/register_missing_parameters.json.twig\"\n    status: 422\n    headers:\n      Content-Type: application/json\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoduo%2Ftutu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoduo%2Ftutu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoduo%2Ftutu/lists"}