{"id":13711875,"url":"https://github.com/delolmo/symfony-router","last_synced_at":"2026-02-01T23:04:25.694Z","repository":{"id":50250511,"uuid":"150946964","full_name":"delolmo/symfony-router","owner":"delolmo","description":"PSR-15 middleware to use the symfony/routing component and store the route attributes in the request.","archived":false,"fork":false,"pushed_at":"2025-11-18T11:33:26.000Z","size":328,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T13:16:39.450Z","etag":null,"topics":["http","middleware","psr-15","psr-7","router","symfony","symfony-router"],"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/delolmo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-30T08:18:13.000Z","updated_at":"2025-11-18T11:33:28.000Z","dependencies_parsed_at":"2023-12-15T17:25:36.293Z","dependency_job_id":"e43803c3-d031-4f3f-ae9c-477bbce04bda","html_url":"https://github.com/delolmo/symfony-router","commit_stats":{"total_commits":56,"total_committers":5,"mean_commits":11.2,"dds":0.125,"last_synced_commit":"378e39b862dcfd65068e01480068f71c7c7422ca"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/delolmo/symfony-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delolmo%2Fsymfony-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delolmo%2Fsymfony-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delolmo%2Fsymfony-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delolmo%2Fsymfony-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delolmo","download_url":"https://codeload.github.com/delolmo/symfony-router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delolmo%2Fsymfony-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28993788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T22:01:47.507Z","status":"ssl_error","status_checked_at":"2026-02-01T21:58:37.335Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["http","middleware","psr-15","psr-7","router","symfony","symfony-router"],"created_at":"2024-08-02T23:01:12.526Z","updated_at":"2026-02-01T23:04:25.688Z","avatar_url":"https://github.com/delolmo.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["Router"],"readme":"# delolmo/symfony-router\n\n [![Packagist Version](https://img.shields.io/packagist/v/delolmo/symfony-router.svg?style=flat-square)](https://packagist.org/packages/delolmo/symfony-router)\n [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nPSR-15 middleware to use the symfony/routing component and store the route attributes in the request.\n\n## Requirements\n\n* PHP \u003e=8.4\n* A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)\n* A [PSR-17 http factory](https://www.php-fig.org/psr/psr-17/)\n\n## Installation\n\nThis package is installable and autoloadable via Composer as [delolmo/symfony-router](https://packagist.org/packages/delolmo/symfony-router).\n\n```sh\ncomposer require delolmo/symfony-router\n```\n\n## Example\n\nConsider Symfony's PhpFileLoader to load route definitions from the following file:\n\n``` php\n# routes.php\n\nuse App\\Controller\\BlogController;\nuse Symfony\\Component\\Routing\\RouteCollection;\nuse Symfony\\Component\\Routing\\Route;\n\n$routes = new RouteCollection();\n$routes-\u003eadd('blog_list', new Route('/blog', array(\n    'request-handler' =\u003e [BlogController::class, 'list']\n)));\n$routes-\u003eadd('blog_show', new Route('/blog/{slug}', array(\n    'request-handler' =\u003e [BlogController::class, 'show']\n)));\n\nreturn $routes;\n\n```\n\nFor this example, we will be using `middlewares/utils` for a PSR-15 compliant \ndispatcher. See [link](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)\nfor more PSR-15 implementations.\n\nThis example uses a basic anonymous function to print the route's attributes:\n\n```php\n\nuse Laminas\\Diactoros\\Response\\HtmlResponse;\nuse Laminas\\Diactoros\\ResponseFactory;\nuse Laminas\\Diactoros\\ServerRequest;\nuse Middlewares\\Utils\\Dispatcher;\nuse Symfony\\Component\\Config\\FileLocator;\nuse Symfony\\Component\\Routing\\Loader\\PhpFileLoader;\nuse Symfony\\Component\\Routing\\RequestContext;\nuse Symfony\\Component\\Routing\\Router;\n\n$fileLocator = new FileLocator(array(__DIR__));\n\n$router = new Router(\n    new PhpFileLoader($fileLocator),\n    'routes.php',\n    array('cache_dir' =\u003e __DIR__ . '/cache'),\n    new RequestContext('/')\n);\n\n$responseFactory = new ResponseFactory();\n\n$dispatcher = new Dispatcher([\n    new DelOlmo\\Middleware\\SymfonyRouterMiddleware($router, $responseFactory),\n    function($request, $next) {\n        return new HtmlResponse(json_encode($request-\u003egetAttributes()));\n    }\n]);\n\n// Try matching a /blog request\n$response = $dispatcher-\u003edispatch(new ServerRequest([], [], '/blog'));\n\n// Will return {\"_route\": \"blog_list\", \"request-handler\" =\u003e [\"App\\Controller\\BlogController\", \"list\"]}\n$c-\u003eget('emitter')-\u003eemit($response);\n\n// Try matching a /blog/hello-world request\n$response = $dispatcher-\u003edispatch(new ServerRequest([], [], '/blog/hello-world'));\n\n// Will return {\"_route\": \"blog_show\", \"request-handler\" =\u003e [\"App\\Controller\\BlogController\", \"show\"], \"slug\" =\u003e \"hello-world\"}\n$c-\u003eget('emitter')-\u003eemit($response);\n\n```\n\n## Options\n\nThe constructor takes two arguments:\n\n```php\n__construct(\n    \\Symfony\\Component\\Routing\\Router $router,\n    \\Psr\\Http\\Message\\ResponseFactoryInterface $responseFactory\n)\n```\n\nThe router instance to use and a PSR-17 factory to create the error \nresponses (`404` or `405`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelolmo%2Fsymfony-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelolmo%2Fsymfony-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelolmo%2Fsymfony-router/lists"}