{"id":22666895,"url":"https://github.com/piko-framework/router","last_synced_at":"2025-09-18T08:45:52.431Z","repository":{"id":57041558,"uuid":"410042839","full_name":"piko-framework/router","owner":"piko-framework","description":"A lightweight and fast router for PHP","archived":false,"fork":false,"pushed_at":"2023-03-04T15:19:31.000Z","size":84,"stargazers_count":65,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-31T04:08:58.582Z","etag":null,"topics":["php","radix","radix-tree","radix-trie","router","routing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piko-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-09-24T17:08:30.000Z","updated_at":"2025-02-05T04:08:12.000Z","dependencies_parsed_at":"2024-01-16T12:01:25.091Z","dependency_job_id":null,"html_url":"https://github.com/piko-framework/router","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.05882352941176472,"last_synced_commit":"5569784f34f6dcfc2db1ae403c253342a2b5d6ef"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/piko-framework/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piko-framework","download_url":"https://codeload.github.com/piko-framework/router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Frouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275738663,"owners_count":25519596,"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","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["php","radix","radix-tree","radix-trie","router","routing"],"created_at":"2024-12-09T14:32:13.068Z","updated_at":"2025-09-18T08:45:52.384Z","avatar_url":"https://github.com/piko-framework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Piko Router\n\n[![build](https://github.com/piko-framework/router/actions/workflows/php.yml/badge.svg)](https://github.com/piko-framework/router/actions/workflows/php.yml)\n[![Coverage Status](https://coveralls.io/repos/github/piko-framework/router/badge.svg?branch=main)](https://coveralls.io/github/piko-framework/router?branch=main)\n\nA lightweight and blazing fast router (see [benchmarks](#benchmarks)) using a [radix trie](https://en.wikipedia.org/wiki/Radix_tree) to store dynamic routes.\n\nThis router maps routes to user defined handlers and can do the reverse operation (reverse routing).\n\n## Installation\n\nIt's recommended that you use Composer to install Piko Router.\n\n```bash\ncomposer require piko/router\n```\n\n## Usage\n\nA basic example:\n\n```php\nuse Piko\\Router;\n\n$router = new Router();\n$router-\u003eaddRoute('/', 'homeView');\n$router-\u003eaddRoute('/user/:id', 'userView');\n\n$match = $router-\u003eresolve('/');\necho $match-\u003ehandler; // homeView\n\n$match = $router-\u003eresolve('/user/10');\necho $match-\u003ehandler; // userView\necho $match-\u003eparams['id']; // 10\n\n// Use of the $match-\u003ehandler to dispatch an action\n// ...\n\n// Reverse routing\necho $router-\u003egetUrl('homeView'); // /\necho $router-\u003egetUrl('userView', ['id' =\u003e 3]); // /user/3\n```\n\nDynamic handlers:\n\n```php\nuse Piko\\Router;\n\n$router = new Router();\n$router-\u003eaddRoute('/admin/:module/:action', ':module/admin/:action');\n\n$match = $router-\u003eresolve('/admin/user/add');\necho $match-\u003ehandler; // user/admin/add\n\necho $router-\u003egetUrl('blog/admin/index'); // /admin/blog/index\n\n```\n\nAdvanced usage: [See RouterTest.php](tests/RouterTest.php)\n\n## Benchmarks\n\nPiko router comparison against Fastroute (cached) and Symfony router (cached).\n\n### Benchmark against 1000 generated routes\n\n```bash\n./vendor/bin/phpbench run --revs=10000 --report='extends:aggregate,break:[\"benchmark\"]'\n```\n\n```\nSymfonyRouter\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| subject            | set          | revs  | its | mem_peak | mode    | rstdev |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 7.241mb  | 1.243μs | ±2.00% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 7.241mb  | 1.296μs | ±2.40% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 7.241mb  | 1.267μs | ±2.35% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 7.241mb  | 2.007μs | ±1.64% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 7.241mb  | 1.984μs | ±1.87% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 7.241mb  | 1.929μs | ±1.69% |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n\nPikoRouter\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| subject            | set          | revs  | its | mem_peak | mode    | rstdev |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 1.862mb  | 0.327μs | ±1.78% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 1.862mb  | 0.330μs | ±2.37% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 1.862mb  | 0.318μs | ±1.61% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 1.862mb  | 1.308μs | ±1.51% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 1.862mb  | 1.800μs | ±0.72% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 1.862mb  | 1.735μs | ±2.64% |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n\nFastRoute\n+--------------------+--------------+-------+-----+----------+----------+--------+\n| subject            | set          | revs  | its | mem_peak | mode     | rstdev |\n+--------------------+--------------+-------+-----+----------+----------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 3.155mb  | 0.228μs  | ±2.46% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 3.155mb  | 0.213μs  | ±1.19% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 3.155mb  | 0.235μs  | ±1.60% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 3.155mb  | 0.652μs  | ±1.36% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 3.155mb  | 12.908μs | ±1.13% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 3.155mb  | 31.784μs | ±1.53% |\n+--------------------+--------------+-------+-----+----------+----------+--------+\n```\n\n![Routers match against 1000 routes](benchmark/img/bench_1000_routes.png)\n\n### Benchmark against 5000 generated routes\n\n```bash\nROUTES=5000 ./vendor/bin/phpbench run --revs=10000 --report='extends:aggregate,break:[\"benchmark\"]'\n```\n\n```\nSymfonyRouter\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| subject            | set          | revs  | its | mem_peak | mode    | rstdev |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 31.488mb | 3.911μs | ±2.47% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 31.488mb | 3.709μs | ±1.78% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 31.488mb | 3.771μs | ±1.40% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 31.488mb | 4.775μs | ±1.74% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 31.488mb | 4.844μs | ±0.46% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 31.488mb | 5.657μs | ±2.16% |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n\nPikoRouter\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| subject            | set          | revs  | its | mem_peak | mode    | rstdev |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 4.569mb  | 0.312μs | ±1.82% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 4.569mb  | 0.313μs | ±1.01% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 4.569mb  | 0.313μs | ±0.40% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 4.569mb  | 1.242μs | ±1.92% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 4.569mb  | 1.897μs | ±1.36% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 4.569mb  | 1.947μs | ±2.04% |\n+--------------------+--------------+-------+-----+----------+---------+--------+\n\nFastRoute\n+--------------------+--------------+-------+-----+----------+-----------+--------+\n| subject            | set          | revs  | its | mem_peak | mode      | rstdev |\n+--------------------+--------------+-------+-----+----------+-----------+--------+\n| benchStaticRoutes  | Best Case    | 10000 | 5   | 11.248mb | 0.208μs   | ±1.44% |\n| benchStaticRoutes  | Average Case | 10000 | 5   | 11.248mb | 0.211μs   | ±1.33% |\n| benchStaticRoutes  | Worst Case   | 10000 | 5   | 11.248mb | 0.225μs   | ±1.51% |\n| benchDynamicRoutes | Best Case    | 10000 | 5   | 11.248mb | 0.584μs   | ±1.96% |\n| benchDynamicRoutes | Average Case | 10000 | 5   | 11.248mb | 85.164μs  | ±1.09% |\n| benchDynamicRoutes | Worst Case   | 10000 | 5   | 11.248mb | 171.611μs | ±0.84% |\n+--------------------+--------------+-------+-----+----------+-----------+--------+\n```\n\n![Routers match against 5000 routes](benchmark/img/bench_5000_routes.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiko-framework%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiko-framework%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiko-framework%2Frouter/lists"}