{"id":41689586,"url":"https://github.com/heropoo/routing","last_synced_at":"2026-01-24T20:12:32.208Z","repository":{"id":62516011,"uuid":"99674220","full_name":"heropoo/routing","owner":"heropoo","description":"A simple and fast route.Use tree structure storage, fast matching! 一个简单快速的路由，使用树形结构存储匹配更快！","archived":false,"fork":false,"pushed_at":"2022-06-30T17:42:43.000Z","size":87,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T22:50:35.396Z","etag":null,"topics":["php-router","route","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heropoo.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":"2017-08-08T09:16:55.000Z","updated_at":"2024-07-09T09:50:13.000Z","dependencies_parsed_at":"2022-11-02T13:16:05.416Z","dependency_job_id":null,"html_url":"https://github.com/heropoo/routing","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/heropoo/routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heropoo%2Frouting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heropoo%2Frouting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heropoo%2Frouting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heropoo%2Frouting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heropoo","download_url":"https://codeload.github.com/heropoo/routing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heropoo%2Frouting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"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":["php-router","route","router","routing"],"created_at":"2026-01-24T20:12:31.707Z","updated_at":"2026-01-24T20:12:32.202Z","avatar_url":"https://github.com/heropoo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Routing\nA simple and fast route.Use tree structure storage, fast matching!  If you like, order a star for me~ ⭐\n\n一个简单快速的路由，使用树形结构存储匹配更快！ 如果你喜欢，帮我点个star吧~ ⭐\n\n[中文说明](./README_CN.md)\n\n[![Latest Stable Version](https://poser.pugx.org/heropoo/routing/v/stable)](https://packagist.org/packages/heropoo/routing)\n[![Total Downloads](https://poser.pugx.org/heropoo/routing/downloads)](https://packagist.org/packages/heropoo/routing)\n[![License](https://poser.pugx.org/heropoo/routing/license)](./LICENSE)\n\n## Install\nTo install it via `composer`\n```sh\ncomposer require heropoo/routing\n```\n\n## Feature\n- Support restful style route\n- Support route group and add some attributes (like namespace,middleware,prefix..)\n- Support route params and limit param's type\n- Support regex\n- Use tree structure storage, fast matching! \n\n## Example:\n```php\n\u003c?php\n\nrequire_once './vendor/autoload.php';\n\nuse Moon\\Routing\\Router;\nuse Moon\\Routing\\UrlMatchException;\n\n$router = new Router([\n    'namespace'=\u003e'app\\\\controllers',    //support controller namespace\n    'middleware'=\u003e[                     //support middleware\n        'startSession',\n        'verifyCSRFToken',\n        'auth'\n    ],\n    'prefix'=\u003e''                        //support prefix\n]);\n\n// action also can be a Closure\n$router-\u003eget('/', function(){\n    return 'Welcome ＼( ^▽^ )／';\n});\n\n//route parameter\n$router-\u003eget('/hello/{name}', function($name){ // auto pick route param to Closure \n    return 'Hello '.$name;\n});\n\n$router-\u003eget('/login', 'UserController::login', 'login'); // name your route\n$router-\u003epost('login', 'UserController::post_login');\n\n//use route group\n$router-\u003egroup(['prefix'=\u003e'user'], function(Router $router){\n    $router-\u003epost('delete/{id:\\d+}', 'UserController::delete'); // {param:type pattern}\n});\n\n// match GET or POST request method\n$router-\u003ematch(['get', 'post'], '/api', 'ApiController::index');\n\n// match all request method\n$router-\u003eany('/other', 'ApiController::other');\n\n// get all routes\nvar_dump($router-\u003egetRoutes());\n\n/**\n * match request\n * @param string $path Request path, eg： /user/list\n * @param string $method Request method, 'GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS''GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'\n * @return array If not matched throw a UrlMatchException\n * return [\n *   'route' =\u003e $route,  // Route\n *   'params' =\u003e $params // array\n * ];\n *\n */\n$res = $router-\u003edispatch($path, $method);\n\nvar_dump($res);\n\n```\n\nNow use matched result to handle your controller's method or Closure! ＼( ^▽^ )／\n\n## Tests\n```\ncomposer run-script test\n```\n\n## Sponsor\n\n\u003ca href=\"https://www.jetbrains.com/?from=heropoo/routing\"\u003e\u003cimg src=\"https://www.ioio.pw/static-assets/jetbrains-blackandwhite.png\" height=100 alt=\"Jetbrains\" title=\"Jetbrains\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheropoo%2Frouting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheropoo%2Frouting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheropoo%2Frouting/lists"}