{"id":19746960,"url":"https://github.com/jordanbrauer/php-router","last_synced_at":"2026-05-15T22:31:21.311Z","repository":{"id":141962350,"uuid":"88773133","full_name":"jordanbrauer/php-router","owner":"jordanbrauer","description":"An example PHP router/dispatcher system for learning purposes.","archived":false,"fork":false,"pushed_at":"2017-04-23T04:28:53.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-10T20:53:08.720Z","etag":null,"topics":["composer","oop","php","router"],"latest_commit_sha":null,"homepage":null,"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/jordanbrauer.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}},"created_at":"2017-04-19T17:41:12.000Z","updated_at":"2022-02-09T02:13:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd61d7e1-4cf3-4daf-a3a8-b9f5d93fce61","html_url":"https://github.com/jordanbrauer/php-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanbrauer%2Fphp-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanbrauer%2Fphp-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanbrauer%2Fphp-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanbrauer%2Fphp-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jordanbrauer","download_url":"https://codeload.github.com/jordanbrauer/php-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241078423,"owners_count":19905852,"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":["composer","oop","php","router"],"created_at":"2024-11-12T02:16:20.976Z","updated_at":"2025-10-06T22:28:55.562Z","avatar_url":"https://github.com/jordanbrauer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-router\n\nAn example (very simple) PHP router/dispatcher system for learning purposes.\n\n## Setup\n\n```shell\n$ git clone https://github.com/jordanbrauer/php-router.git\n$ cd ./php-router\n$ composer install\n```\n\n## Usage\n\n### Boilerplate\n\nStart by requiring the `autoload.php` file, using the class, and instantiating a new router like so,\n\n```php\nrequire_once 'vendor/autoload.php';\n\nuse \\Jorb\\Router\\Router as Router;\n\n$router = new Router();\n```\n\n### API\n\nNow that you have a new router you can start using, it is time to read about the routers' API and put it to the test!\n\n#### `add()`\n\n\u003e `Router::add(string $route, mixed $method);`\n\nAdd a route to the router.\n\n__Example:__ obligartory hello world\n\n```php\n$router-\u003eadd('/', function () {\n  echo 'Hello World!';\n});\n```\n\n__Example:__ Route w/ argument\n\n```php\n$router-\u003eadd('/user/.+', function ($user) {\n  echo \"Welcome {$user}!\";\n});\n```\n\n__Example:__ Route w/ many arguments\n\n_Note: this feature is currently bugged and does not work as intended. The dispatch method will match multiple routes if a longer route such as the one below contains an already existing shorter route in its' path._\n\n```php\n$router-\u003eadd('/user/.+/repository/.+', function($user, $repository) {\n  echo \"Repository: {$user}/{$repository}\";\n})\n```\n\n#### `dispatch()`\n\n\u003e `Router::dispatch();`\n\nRoute the user to all appropriate destinations when requested.\n\n__Example:__\n\n```php\n$router-\u003edispatch();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanbrauer%2Fphp-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordanbrauer%2Fphp-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanbrauer%2Fphp-router/lists"}