{"id":16619048,"url":"https://github.com/jasny/dummy-middleware","last_synced_at":"2026-04-13T07:37:26.050Z","repository":{"id":56996772,"uuid":"175093944","full_name":"jasny/dummy-middleware","owner":"jasny","description":"Dummy PSR-7 middleware (null object)","archived":false,"fork":false,"pushed_at":"2019-10-24T03:43:08.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-27T01:26:39.026Z","etag":null,"topics":["dummy","middleware","null-object-pattern","php7","psr-15","psr-7"],"latest_commit_sha":null,"homepage":null,"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/jasny.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":"2019-03-11T22:32:54.000Z","updated_at":"2019-10-24T03:43:10.000Z","dependencies_parsed_at":"2022-08-21T11:10:16.931Z","dependency_job_id":null,"html_url":"https://github.com/jasny/dummy-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jasny/dummy-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasny%2Fdummy-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasny%2Fdummy-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasny%2Fdummy-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasny%2Fdummy-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasny","download_url":"https://codeload.github.com/jasny/dummy-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasny%2Fdummy-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31744404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T06:26:45.479Z","status":"ssl_error","status_checked_at":"2026-04-13T06:26:44.645Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dummy","middleware","null-object-pattern","php7","psr-15","psr-7"],"created_at":"2024-10-12T02:22:36.839Z","updated_at":"2026-04-13T07:37:26.032Z","avatar_url":"https://github.com/jasny.png","language":"PHP","readme":"Jasny Dummy Middleware\n===\n\n[![Build Status](https://travis-ci.org/jasny/dummy-middleware.svg?branch=master)](https://travis-ci.org/jasny/dummy-middleware)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jasny/dummy-middleware/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jasny/dummy-middleware/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/jasny/dummy-middleware/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/jasny/dummy-middleware/?branch=master)\n[![Packagist Stable Version](https://img.shields.io/packagist/v/jasny/dummy-middleware.svg)](https://packagist.org/packages/jasny/dummy-middleware)\n[![Packagist License](https://img.shields.io/packagist/l/jasny/dummy-middleware.svg)](https://packagist.org/packages/jasny/dummy-middleware)\n\nDummy client and server middleware for PSR-7 requests. Works both as PSR-15 and double pass middleware.\n\nThe dummy services work as [null objects](https://sourcemaking.com/design_patterns/null_object) / passthrough,\npreventing the use of if's.\n\nInstallation\n---\n\n    composer require jasny/dummy-middleware\n\nUsage\n---\n\n### Server middleware\n\nServer middleware can be used all passthrough of PSR-7 server requests.\n\n#### Single pass middleware (PSR-15)\n\nThe middleware implements the PSR-15 `MiddlewareInterface`. As PSR standard many new libraries support this type of\nmiddleware, for example [Zend Stratigility](https://docs.zendframework.com/zend-stratigility/). \n\n```php\nuse Jasny\\Dummy\\ServerMiddleware;\nuse Zend\\Stratigility\\MiddlewarePipe;\nuse Zend\\Diactoros\\ResponseFactory;\n\n$middleware = new ServerMiddleware();\n\n$app = new MiddlewarePipe();\n$app-\u003epipe($middleware);\n```\n\n#### Double pass middleware\n\nMany PHP libraries support double pass middleware. These are callables with the following signature;\n\n```php\nfn(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface\n```\n\nTo get a callback to be used by libraries as [Jasny Router](https://github.com/jasny/router) and\n[Relay](http://relayphp.com/), use the `asDoublePass()` method.\n\n```php\nuse Jasny\\Dummy\\ServerMiddleware;\nuse Relay\\RelayBuilder;\n\n$middleware = new ServerMiddleware();\n\n$relayBuilder = new RelayBuilder($resolver);\n$relay = $relayBuilder-\u003enewInstance([\n    $middleware-\u003easDoublePass(),\n]);\n\n$response = $relay($request, $baseResponse);\n```\n\n### Client middleware\n\nClient middleware can be used for PSR-7 compatible HTTP clients like [Guzzle](http://docs.guzzlephp.org) and\n[HTTPlug](http://docs.php-http.org).\n\n#### Double pass middleware\n\nThe client middleware can be used by any client that does support double pass middleware. Such middleware are callables\nwith the following signature;\n\n```php\nfn(RequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface\n```\n\nMost HTTP clients do not support double pass middleware, but a type of single pass instead. However more general\npurpose PSR-7 middleware libraries, like [Relay](http://relayphp.com/), do support double pass.\n\n```php\nuse Relay\\RelayBuilder;\nuse Jasny\\Dummy\\ClientMiddleware;\n\n$middleware = new ClientMiddleware();\n\n$relayBuilder = new RelayBuilder($resolver);\n$relay = $relayBuilder-\u003enewInstance([\n    $middleware-\u003easDoublePass(),\n]);\n\n$response = $relay($request, $baseResponse);\n```\n\n_The client middleware does not conform to PSR-15 (single pass) as that is intended for server requests only._\n\n#### Guzzle\n\n[Guzzle](http://docs.guzzlephp.org) is the most popular HTTP Client for PHP. The middleware has a `forGuzzle()` method\nthat creates a callback which can be used as Guzzle middleware.\n\n```php\nuse GuzzleHttp\\HandlerStack;\nuse GuzzleHttp\\Client;\nuse Jasny\\Dummy\\ClientMiddleware;\n\n$middleware = new ClientMiddleware();\n\n$stack = new HandlerStack();\n$stack-\u003epush($middleware-\u003eforGuzzle());\n\n$client = new Client(['handler' =\u003e $stack]);\n```\n\n#### HTTPlug\n\n[HTTPlug](http://docs.php-http.org/en/latest/httplug/introduction.html) is the HTTP client of PHP-HTTP. It allows you\nto write reusable libraries and applications that need an HTTP client without binding to a specific implementation.\n\nThe `forHttplug()` method for the middleware creates an object that can be used as HTTPlug plugin.\n\n```php\nuse Http\\Discovery\\HttpClientDiscovery;\nuse Http\\Client\\Common\\PluginClient;\nuse Jasny\\Dummy\\ClientMiddleware;\n\n$middleware = new ClientMiddleware();\n\n$pluginClient = new PluginClient(\n    HttpClientDiscovery::find(),\n    [\n        $middleware-\u003eforHttplug(),\n    ]\n);\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasny%2Fdummy-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasny%2Fdummy-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasny%2Fdummy-middleware/lists"}