{"id":17548886,"url":"https://github.com/xujiajun/tast-router","last_synced_at":"2025-10-24T20:39:24.249Z","repository":{"id":57085270,"uuid":"39051461","full_name":"xujiajun/tast-router","owner":"xujiajun","description":"A Simple PHP  Router","archived":false,"fork":false,"pushed_at":"2017-07-15T05:05:45.000Z","size":37,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T02:13:19.454Z","etag":null,"topics":["php","php-router","tast"],"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/xujiajun.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":"2015-07-14T03:29:05.000Z","updated_at":"2019-07-24T13:21:58.000Z","dependencies_parsed_at":"2022-08-25T00:50:26.334Z","dependency_job_id":null,"html_url":"https://github.com/xujiajun/tast-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/xujiajun%2Ftast-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Ftast-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Ftast-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Ftast-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xujiajun","download_url":"https://codeload.github.com/xujiajun/tast-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546096,"owners_count":21448262,"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":["php","php-router","tast"],"created_at":"2024-10-21T02:46:12.856Z","updated_at":"2025-10-24T20:39:19.203Z","avatar_url":"https://github.com/xujiajun.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TastRouter  [![License](https://poser.pugx.org/xujiajun/tast-router/license)](https://packagist.org/packages/xujiajun/tast-router) [![Code Climate](https://codeclimate.com/github/xujiajun/tast-router/badges/gpa.svg)](https://codeclimate.com/github/xujiajun/tast-router) [![Build Status](https://travis-ci.org/xujiajun/tast-router.svg?branch=master)](https://travis-ci.org/xujiajun/tast-router)\n\nA Simple PHP Router\n\n* 支持RESTful风格\n* 支持反向路由\n* 支持动态参数绑定\n* 支持对参数正则检验\n* 支持Yaml格式的路由配置\n\n## Requirements\n\n  PHP5.4+\n\n## composer方式获得\n\n```\n{\n    \"require\":{\n        \"xujiajun/tast-router\":\"dev-master\"\n    }\n}\n\n```\n当然也可以直接clone\n\n## Usage\n\nstep1\n```\nsudo composer install\n```\n\nstep2:\n```\n\n//web/index.php\n\nrequire __DIR__.'/../vendor/autoload.php';\nuse TastRouter\\Route;\nuse TastRouter\\Router;\nuse TastRouter\\RouteCollection;\n\n$collection = new RouteCollection();\n\n$controller = 'TastRouter\\\\App\\\\Controllers\\\\UserController';\n\n//普通用法\n$collection\n-\u003eattachRoute(new Route('/user/do',[\n    '_controller' =\u003e \"$controller::doAction\",\n    'methods' =\u003e 'GET',\n]));\n\n//使用正则\n$collection\n-\u003eattachRoute(new Route('/user/{user}',[\n    '_controller' =\u003e \"$controller::indexAction\",\n    'methods' =\u003e 'GET',\n    'user'=\u003e'\\w+',\n//    'id'=\u003e'\\d+',\n]));\n\n//路由名绑定\n$collection\n-\u003eattachRoute(new Route('/hello/{hello}',[\n    '_controller' =\u003e \"$controller::indexAction\",\n    'methods' =\u003e 'GET',\n    'hello'=\u003e'\\w+',\n    'routeName'=\u003e'say_hello',//bind route name\n//    'id'=\u003e'\\d+',\n]));\n\n\n$router = new Router($collection);\n$route = $router-\u003ematchCurrentRequest();\n\n//解析路由\necho $router-\u003egenerate('say_hello',['hello'=\u003e'xujiajun']);// 输出 /hello/xujiajun\n\n```\n以上用法太麻烦？\n\nTastRouter也支持Yaml的配置.方便管理你的路由:\n\n```\n//web/index.php\n\nrequire __DIR__.'/../vendor/autoload.php';\nuse TastRouter\\Router;\nuse Symfony\\Component\\Yaml\\Yaml;\n\n$file = __DIR__.'/../src/Config/routes.yml';\n$array = Yaml::parse(file_get_contents($file));\n$router = Router::parseConfig($array);\n$route = $router-\u003ematchCurrentRequest();\n\n```\n\n## License\n[MIT Licensed](http://www.opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxujiajun%2Ftast-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxujiajun%2Ftast-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxujiajun%2Ftast-router/lists"}