{"id":19458864,"url":"https://github.com/leafsphp/router","last_synced_at":"2025-04-25T06:30:36.289Z","repository":{"id":56871357,"uuid":"420290007","full_name":"leafsphp/router","owner":"leafsphp","description":"🏚 router module for leaf PHP","archived":true,"fork":false,"pushed_at":"2024-10-02T10:32:43.000Z","size":48,"stargazers_count":6,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T00:24:37.241Z","etag":null,"topics":["leafphp","php","router"],"latest_commit_sha":null,"homepage":"https://leafphp.dev/modules/router/","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/leafsphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"open_collective":"leaf","github":"leafsphp"}},"created_at":"2021-10-23T02:00:48.000Z","updated_at":"2024-10-15T11:35:59.000Z","dependencies_parsed_at":"2023-02-09T11:01:54.531Z","dependency_job_id":"ef4fa998-0efa-49a5-a83a-dad7d46e5d7f","html_url":"https://github.com/leafsphp/router","commit_stats":{"total_commits":51,"total_committers":2,"mean_commits":25.5,"dds":"0.039215686274509776","last_synced_commit":"dc3744718289975145bced2aa5c5f3e8ca022f19"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafsphp","download_url":"https://codeload.github.com/leafsphp/router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250766977,"owners_count":21483898,"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":["leafphp","php","router"],"created_at":"2024-11-10T17:28:47.441Z","updated_at":"2025-04-25T06:30:36.272Z","avatar_url":"https://github.com/leafsphp.png","language":"PHP","readme":"\u003c!-- markdownlint-disable no-inline-html --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg src=\"https://leafphp.netlify.app/assets/img/leaf3-logo.png\" height=\"100\"/\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eLeaf Router\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/router\"\n\t\t\u003e\u003cimg\n\t\t\tsrc=\"https://poser.pugx.org/leafs/router/v/stable\"\n\t\t\talt=\"Latest Stable Version\"\n\t/\u003e\u003c/a\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/router\"\n\t\t\u003e\u003cimg\n\t\t\tsrc=\"https://poser.pugx.org/leafs/router/downloads\"\n\t\t\talt=\"Total Downloads\"\n\t/\u003e\u003c/a\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/router\"\n\t\t\u003e\u003cimg\n\t\t\tsrc=\"https://poser.pugx.org/leafs/router/license\"\n\t\t\talt=\"License\"\n\t/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\nLeaf router is the core routing engine which powers the Leaf PHP framework. Leaf router is now served as a serve-yourself module which can even be used outside the Leaf ecosystem.\n\n**Leaf Router is still built into Leaf Core and doesn't need to be installed separately.**\n\n## Installation\n\nYou can easily install Leaf using [Composer](https://getcomposer.org/).\n\n```bash\ncomposer require leafs/router\n```\n\n## Basic Usage\n\nIf you are using leaf router with Leaf, you can build your leaf apps just as you've always done:\n\n```php\n\u003c?php\nrequire __DIR__ . \"vendor/autoload.php\";\n\n// GET example\napp()-\u003eget(\"/\", function () {\n  response()-\u003ejson([\n    \"message\" =\u003e \"Welcome!\"\n  ]);\n});\n\n// MATCH example\napp()-\u003ematch(\"GET\", \"/test\", function () {\n  response()-\u003ejson([\n    \"message\" =\u003e \"Test!\"\n  ]);\n});\n\napp()-\u003erun();\n```\n\nIf however, you are using leaf router outside of the leaf framework, you simply need to call these methods on the `Leaf\\Router` object:\n\n```php\n\u003c?php\n\nuse Leaf\\Router;\n\nrequire __DIR__ . \"vendor/autoload.php\";\n\n// GET example\nRouter::get(\"/\", function () {\n  echo json_encode([\n    \"message\" =\u003e \"Welcome!\"\n  ]);\n});\n\n// MATCH example\nRouter::match(\"GET\", \"/test\", function () {\n  echo json_encode([\n    \"message\" =\u003e \"Test!\"\n  ]);\n});\n\nRouter::run();\n```\n\nYou may quickly test this using the built-in PHP server:\n\n```bash\nphp -S localhost:8000\n```\n\n## 💬 Stay In Touch\n\n- [Twitter](https://twitter.com/leafphp)\n- [Join the forum](https://github.com/leafsphp/leaf/discussions/37)\n- [Chat on discord](https://discord.com/invite/Pkrm9NJPE3)\n\n## 📓 Learning Leaf 3\n\n- Leaf has a very easy to understand [documentation](https://leafphp.dev) which contains information on all operations in Leaf.\n- You can also check out our [youtube channel](https://www.youtube.com/channel/UCllE-GsYy10RkxBUK0HIffw) which has video tutorials on different topics\n- We are also working on codelabs which will bring hands-on tutorials you can follow and contribute to.\n\n## 😇 Contributing\n\nWe are glad to have you. All contributions are welcome! To get started, familiarize yourself with our [contribution guide](https://leafphp.dev/community/contributing.html) and you'll be ready to make your first pull request 🚀.\n\nTo report a security vulnerability, you can reach out to [@mychidarko](https://twitter.com/mychidarko) or [@leafphp](https://twitter.com/leafphp) on twitter. We will coordinate the fix and eventually commit the solution in this project.\n\n### Code contributors\n\n\u003ctable\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"https://github.com/mychidarko\"\u003e\n\t\t\t\t\u003cimg src=\"https://avatars.githubusercontent.com/u/26604242?v=4\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\n\t\t\t\t\t\u003cb\u003eMichael Darko\u003c/b\u003e\n\t\t\t\t\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\n## 🤩 Sponsoring Leaf\n\nYour cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on [open collective](https://opencollective.com/leaf) or check the [contribution page](https://leafphp.dev/support/) for a list of ways to contribute.\n\nAnd to all our existing cash/code contributors, we love you all ❤️\n\n### Cash contributors\n\n\u003ctable\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"https://opencollective.com/aaron-smith3\"\u003e\n\t\t\t\t\u003cimg src=\"https://images.opencollective.com/aaron-smith3/08ee620/avatar/256.png\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\u003cb\u003eAaron Smith\u003c/b\u003e\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"https://opencollective.com/peter-bogner\"\u003e\n\t\t\t\t\u003cimg src=\"https://images.opencollective.com/peter-bogner/avatar/256.png\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\u003cb\u003ePeter Bogner\u003c/b\u003e\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"#\"\u003e\n\t\t\t\t\u003cimg src=\"https://images.opencollective.com/guest-32634fda/avatar.png\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\u003cb\u003eVano\u003c/b\u003e\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003ca href=\"#\"\u003e\n        \u003cimg\n          src=\"https://images.opencollective.com/guest-c72a498e/avatar.png\"\n          width=\"120px\"\n          alt=\"\"\n        /\u003e\n        \u003cbr /\u003e\n        \u003csub\u003e\u003cb\u003eCasprine\u003c/b\u003e\u003c/sub\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n\t\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"https://github.com/doc-han\"\u003e\n\t\t\t\t\u003cimg src=\"https://avatars.githubusercontent.com/u/35382021?v=4\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\u003cb\u003eFarhan Yahaya\u003c/b\u003e\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n\t\t\t\u003ca href=\"https://www.lucaschaplain.design/\"\u003e\n\t\t\t\t\u003cimg src=\"https://images.opencollective.com/sptaule/aa5f956/avatar/256.png\" width=\"120px\" alt=\"\"/\u003e\n\t\t\t\t\u003cbr /\u003e\n\t\t\t\t\u003csub\u003e\u003cb\u003eLucas Chaplain\u003c/b\u003e\u003c/sub\u003e\n\t\t\t\u003c/a\u003e\n\t\t\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## 🤯 Links/Projects\n\n- [Aloe CLI](https://leafphp.dev/aloe-cli/)\n- [Leaf Docs](https://leafphp.dev)\n- [Leaf MVC](https://mvc.leafphp.dev)\n- [Leaf API](https://api.leafphp.dev)\n- [Leaf CLI](https://cli.leafphp.dev)\n","funding_links":["https://opencollective.com/leaf","https://github.com/sponsors/leafsphp","https://opencollective.com/aaron-smith3","https://opencollective.com/peter-bogner"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafsphp%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Frouter/lists"}