{"id":20980594,"url":"https://github.com/php-api-clients/middleware","last_synced_at":"2025-05-14T15:30:44.402Z","repository":{"id":52453208,"uuid":"71337083","full_name":"php-api-clients/middleware","owner":"php-api-clients","description":":rainbow:","archived":false,"fork":false,"pushed_at":"2023-12-15T02:22:19.000Z","size":318,"stargazers_count":1,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T18:25:13.627Z","etag":null,"topics":["hacktoberfest","middleware","php","php7","reactphp"],"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/php-api-clients.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-19T08:46:00.000Z","updated_at":"2020-10-04T20:12:19.000Z","dependencies_parsed_at":"2024-06-20T00:07:20.664Z","dependency_job_id":"8536fe30-05dc-4da1-9226-428cb327e41a","html_url":"https://github.com/php-api-clients/middleware","commit_stats":{"total_commits":249,"total_committers":6,"mean_commits":41.5,"dds":"0.10441767068273089","last_synced_commit":"8e9eff690cb44c1171486c75a2e61a575a88e0fe"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-api-clients%2Fmiddleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-api-clients%2Fmiddleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-api-clients%2Fmiddleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-api-clients%2Fmiddleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-api-clients","download_url":"https://codeload.github.com/php-api-clients/middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254171569,"owners_count":22026464,"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":["hacktoberfest","middleware","php","php7","reactphp"],"created_at":"2024-11-19T05:29:14.706Z","updated_at":"2025-05-14T15:30:43.004Z","avatar_url":"https://github.com/php-api-clients.png","language":"PHP","readme":"# API Client middleware for PHP 7.x\n\n[![Build Status](https://travis-ci.org/php-api-clients/middleware.svg?branch=master)](https://travis-ci.org/php-api-clients/middleware)\n[![Latest Stable Version](https://poser.pugx.org/api-clients/middleware/v/stable.png)](https://packagist.org/packages/api-clients/middleware)\n[![Total Downloads](https://poser.pugx.org/api-clients/middleware/downloads.png)](https://packagist.org/packages/api-clients/middleware/stats)\n[![Code Coverage](https://scrutinizer-ci.com/g/php-api-clients/middleware/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-api-clients/middleware/?branch=master)\n[![License](https://poser.pugx.org/api-clients/middleware/license.png)](https://packagist.org/packages/api-clients/middleware)\n[![PHP 7 ready](http://php7ready.timesplinter.ch/php-api-clients/middleware/badge.svg)](https://appveyor-ci.org/php-api-clients/middleware)\n\nThis library contains the a async `MiddlewareRunner` used in our api clients. It \nprovides an interface for all middlewares. Middlewares are ordered by priority\nwhen they where added to the `MiddlewareRunner`. Order of middlewares with the\nsame priority is not guaranteed.\n\nA number of traits are provided for your convenience, if your middleware\nimplementation does not require all the methods defined in the \n`MiddlewareInterface`.\n\n## Locator\nThe locator can be used by your application to fetch middleware instances.\nIt will check whether the created instance implements the `MiddlewareInterface`.\nCurrently the only provided locator is the `ContainerLocator` which accepts a\n`Psr\\Container\\ContainerInterface` to fetch your middleware instances.\n\n## Example\n```php\n    $container = /* ... */;\n    $locator = new ContainerLocator($container);\n    $middlewares = [];\n    \n    $config = [\n        'middlewares' =\u003e [/*...*/]\n        'options' =\u003e [/*...*/]\n    ];\n       \n    foreach ($config['middlewares'] as $middleware) {\n       $middlewares[] = $locator-\u003eget($middleware);\n    }\n    \n    $runner = new MiddlewareRunner($config['options'], $middelwares);\n    \n    $runner-\u003epre($request)-\u003ethen(function ($request) use ($options) {\n        return resolve($this-\u003ebrowser-\u003esend(\n            $request\n        ));\n    }, function (ResponseInterface $response) {\n        return resolve($response);\n    })-\u003ethen(function (ResponseInterface $response) use ($runner) {\n        return $runner-\u003epost($response);\n    })-\u003eotherwise(function (Throwable $throwable) use ($runner) {\n        return reject($runner-\u003eerror($throwable));\n    });\n```\n\n\n# License\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 Cees-Jan Kiewiet\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-api-clients%2Fmiddleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-api-clients%2Fmiddleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-api-clients%2Fmiddleware/lists"}