{"id":19593930,"url":"https://github.com/edsonbonfim/php-http-router","last_synced_at":"2025-07-16T06:36:50.109Z","repository":{"id":62495841,"uuid":"124523883","full_name":"edsonbonfim/PHP-HTTP-Router","owner":"edsonbonfim","description":"A fast and powerful router that maps route callbacks to specific HTTP request methods and URIs. It supports parameters and pattern matching","archived":false,"fork":false,"pushed_at":"2019-12-12T00:08:01.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-29T06:54:40.451Z","etag":null,"topics":["php","php-router","php7","psr-7","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/edsonbonfim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-09T10:10:47.000Z","updated_at":"2022-02-12T12:35:55.000Z","dependencies_parsed_at":"2022-11-02T11:45:28.292Z","dependency_job_id":null,"html_url":"https://github.com/edsonbonfim/PHP-HTTP-Router","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edsonbonfim/PHP-HTTP-Router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-HTTP-Router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-HTTP-Router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-HTTP-Router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-HTTP-Router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edsonbonfim","download_url":"https://codeload.github.com/edsonbonfim/PHP-HTTP-Router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-HTTP-Router/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265488766,"owners_count":23775176,"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","php7","psr-7","router","routing"],"created_at":"2024-11-11T08:41:47.166Z","updated_at":"2025-07-16T06:36:50.044Z","avatar_url":"https://github.com/edsonbonfim.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Router\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require bonfim/router\n```\n\nBasic Usage\n-----------\n\nInclude the autoloader of composer:\n\n```php\n\u003c?php\n\ninclude 'vendor/autoload.php';\n```\n\nand define your routes:\n\n```php\nuse Bonfim\\Router\\Route;\n\nRoute::get('/', function () {\n    echo 'Hello World!';\n});\n```\n\nRouting\n-------\n\nThe routing is done by matching a URL pattern with a callback function:\n\n```php\nRoute::get('/', function () {\n    echo 'Hello World!';\n});\n```\n\nThe callback can be any object that is callable. So you can use a regular function:\n\n```php\nfunction hello()\n{\n    echo 'Hello World!';\n}\n\nRoute::get('/', 'hello');\n```\n\nOr a class method:\n\n```php\nclass Greeting\n{\n    public static function hello()\n    {\n        echo 'Hello World!';    \n    }\n}\n\nRoute::get('/', ['Greeting', 'hello']);\n```\n\nOr an object method:\n\n```php\nclass Greeting\n{\n    private $name;\n\n    public function __construct()\n    {\n        $this-\u003ename = 'Edson Onildo';\n    }\n\n    public function hello()\n    {\n        echo 'Hello, {$this-\u003ename}!';    \n    }\n}\n\n$greeting = new Greeting();\n\nRoute::get('/', [$greeting, 'hello']);\n```\n\nRoutes are matched in the order they are defined. The first route to match a request will be invoked.\n\nMethod Routing\n--------------\n\nThe router allows you to register routes that respond to any HTTP verb:\n\n```php\nRoute::get($uri, $callback);\nRoute::post($uri, $callback);\nRoute::put($uri, $callback);\nRoute::patch($uri, $callback);\nRoute::delete($uri, $callback);\nRoute::options($uri, $callback);\n```\n\nYou may register a route that responds to multiple verbs using the ```match``` method:\n\n```php\nRoute::match(['get', 'post'], '/', function() {\n    //\n});\n```\n\nOr, you may even register a route that responds to all HTTP verbs using the ```any``` method:\n\n```php\nRoute::any('/', function() {\n    //\n});\n```\n\nNamed Parameters\n----------------\n\nYou may specify named parameters in your routes which will be passed along to your callback function:\n\n```php\nRoute::get('/@name/@id', function($name, $id) {\n    echo \"hello, $name ($id)!\";\n});\n```\n\nYou can also include regular expressions with your named parameters by using the : delimiter:\n\n```php\nRoute::get('/@name/@id:[0-9]{3}', function($name, $id) {\n    // This will match /bob/123\n    // But will not match /bob/12345\n});\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email inbox.edsononildo@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Edson Onildo][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/bonfim/router.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/BonfimLabs/PHP-HTTP-Router/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/BonfimLabs/PHP-HTTP-Router.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/BonfimLabs/PHP-HTTP-Router.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/bonfim/router.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/bonfim/router\n[link-travis]: https://travis-ci.org/BonfimLabs/PHP-HTTP-Router\n[link-scrutinizer]: https://scrutinizer-ci.com/g/BonfimLabs/PHP-HTTP-Router/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/BonfimLabs/PHP-HTTP-Router\n[link-downloads]: https://packagist.org/packages/bonfim/router\n[link-author]: https://github.com/EdsonOnildoJR\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsonbonfim%2Fphp-http-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedsonbonfim%2Fphp-http-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsonbonfim%2Fphp-http-router/lists"}