{"id":15296342,"url":"https://github.com/bitnbytesio/router","last_synced_at":"2026-01-05T09:08:23.650Z","repository":{"id":62488080,"uuid":"138009102","full_name":"bitnbytesio/router","owner":"bitnbytesio","description":"Fast and simple request router for PHP7","archived":false,"fork":false,"pushed_at":"2018-06-20T09:24:20.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T05:26:36.708Z","etag":null,"topics":["php7","php71","router","routing"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitnbytesio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-20T09:20:28.000Z","updated_at":"2022-02-12T08:33:07.000Z","dependencies_parsed_at":"2022-11-02T11:01:42.696Z","dependency_job_id":null,"html_url":"https://github.com/bitnbytesio/router","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnbytesio%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnbytesio%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnbytesio%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnbytesio%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitnbytesio","download_url":"https://codeload.github.com/bitnbytesio/router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407755,"owners_count":20610232,"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":["php7","php71","router","routing"],"created_at":"2024-09-30T18:10:10.289Z","updated_at":"2026-01-05T09:08:23.644Z","avatar_url":"https://github.com/bitnbytesio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Router - Simple/Fast request router for PHP7\n=======================================\n\nInstall\n-------\n\nTo install with composer:\n\n```sh\ncomposer require artisangang/router\n```\n\nRequires PHP 7.\n\nUsage\n-----\n\n```php\n\u003c?php\n\nrequire '/path/to/vendor/autoload.php';\n\n// storage for locked routes\n$storage = new \\Router\\FileStorage(__DIR__);\n\n$routeManager = new \\Router\\Manager;\n$routeManager-\u003estorage( $storage );\n\n// lock routes in production mode for performance\n$routeManager-\u003elock();\n\nif (isset($_ENV[\"development\"])) {\n    $routeManager-\u003eunlock();\n}\n\n//product routes\n$p = $routeManager-\u003erouter();\n$p-\u003euse('GET /product/', 'IndexController@productIndex');\n$p-\u003euse('GET /product/:id', 'IndexController@productSingle');\n$p-\u003euse('POST /product', 'IndexController.productCreate');\n$p-\u003euse('PUT /product/:id', 'IndexController.productUpdate');\n$p-\u003euse('PATCH /product/:id', 'IndexController.productPatch');\n$p-\u003euse('DELETE /product/:id', 'IndexController.productDelete');\n\n// category routes\n$c = $routeManager-\u003erouter();\n$c-\u003euse('GET /category', 'IndexController.categoryIndex');\n$c-\u003euse('POST /category', 'IndexController.categoryCreate');\n$c-\u003euse('PUT /category/:id', 'IndexController.categoryUpdate');\n$c-\u003euse('PATCH /category/:id', 'IndexController.categoryPatch');\n$c-\u003euse('DELETE /category/:id', 'IndexController.categoryDelete');\n\n// shop routes\n$c-\u003eget('/shop', 'IndexController.shopIndex');\n$c-\u003epost('/shop', 'IndexController.shopCreate');\n$c-\u003eput('/shop/:id', 'IndexController.shopUpdate');\n$c-\u003epatch('/shop/:id', 'IndexController.shopPatch');\n$c-\u003edelete('/shop/:id', 'deleteShop');\n\n// group routes in v1 prefix\n$r = $routeManager-\u003erouter('v1');\n// add routes to group\n$r-\u003echild($p, $c);\n\n// create another group with prefic api\n$a = $routeManager-\u003erouter('api');\n// add route to this gorup\n$a-\u003echild($r);\n\n// find route match based on current request uri, this will return Router\\Commands\\HttpCommand instance if match found\n$request = $routeManager-\u003ematch($a);\n\nif (!$request) {\n    die('404,Page not found!');\n}\n\n// extract params from uri\n// for example with uri /product/1 matched with pattern /product/:id will return ['id' =\u003e 1]\n$params = $request-\u003eparams($routeManager-\u003erequestUri);\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnbytesio%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitnbytesio%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnbytesio%2Frouter/lists"}