{"id":33957089,"url":"https://github.com/tpg/routine","last_synced_at":"2026-06-08T14:31:53.272Z","repository":{"id":56861641,"uuid":"525890859","full_name":"tpg/routine","owner":"tpg","description":"Class-based routing for Laravel","archived":false,"fork":false,"pushed_at":"2022-08-19T10:08:37.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-14T09:38:38.478Z","etag":null,"topics":[],"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/tpg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-17T17:25:46.000Z","updated_at":"2022-08-19T10:09:52.000Z","dependencies_parsed_at":"2022-09-14T10:50:32.427Z","dependency_job_id":null,"html_url":"https://github.com/tpg/routine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tpg/routine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpg%2Froutine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpg%2Froutine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpg%2Froutine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpg%2Froutine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpg","download_url":"https://codeload.github.com/tpg/routine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpg%2Froutine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34067348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-12-12T20:56:23.984Z","updated_at":"2026-06-08T14:31:53.247Z","avatar_url":"https://github.com/tpg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Routine\n\nA really basic solution to class-based routing for Laravel. It's very simplistic and probably needs a lot of work.\nI only wrote this for myself and isn't really intended for the wider world.\n\nI don't intend to provide much support for this package and will likely only update it when I need to. I'm not even sure\nI'll continue to use it. It's more of an experiment really.\n\nBut if you really want to use it, then by all means, install it with Composer:\n\n```shell\ncomposer require thepublicgood/routine\n```\n\nOnce installed, publish the config file with:\n\n```shell\nphp ./artisan vendor:publish --provider=\"TPG\\Routine\\RoutineServiceProvider\"\n```\n\nThis will place a `routine.php` file in your config directory. Now create a new empty class and extend the\n`TPG\\Routine\\RouteRegistrar` class. Create new methods that are prefixed with `map` and suffixed with `Routes`. Routine\nwill call each method and map the defined routes.\n\nEach map method must accept an instance of `Illuminate\\Routing\\Router`:\n\n```php\nuse App\\Http\\Controllers\\SessionController;\nuse Illuminuate\\Routing\\Router;\nuse TPG\\Routine\\RouteRegistrar;\n\nclass AuthRoutes extends RouteRegistrar\n{\n    protected function mapWebRoutes(Router $router): void\n    {\n        $router-\u003emiddleware(['guest'])-\u003egroup(function (Router $router) {\n            \n            $router-\u003eget('/login', [SessionController::class, 'create'])-\u003ename('login');\n            $router-\u003epost('/login', [SessionController::class, 'store']);\n        \n        });\n        \n        $router-\u003emiddleware(['auth'])-\u003epost('/logout', [SessionController:class, 'destroy'])-\u003ename('logout');\n    }\n}\n```\n\nBy default, Routine will set default middleware depending on the name of the method. You can find these defaults in the\n`routine.php` config file. For example, the method `mapWebRoutes` will automatically use the middleware set as the `web`\ndefault. The method `mapApiRoutes` will automatically use the middleware set as the `api` default. This means you could\ncreate a default called `ajax` for example, and the method `mapAjaxRoutes` will automatically set those middleware.\n\n## Middleware Contracts\nIn addition, it can be useful to apply middleware for an entire route file. For example, if you need to specify that\na set of routes need authentication. You can do this by implementing the `TPG\\Routing\\Contracts\\RequiresAuthentication`\ninterface:\n\n```php\nuse Illuminuate\\Routing\\Router;\nuse TPG\\Routine\\Contracts\\RequiresAuthentication;\nuse TPG\\Routine\\RouteRegistrar;\n\nclass DashboardRoutes extends RouteRegistrar implements RequiresAuthentication\n{\n    // ...\n}\n```\n\nRoutine includes a `RequiresAuthentication`, `RequiresSanctumAuthentication` and a `SignedRoute` contract by default.\nIf you add your own, ensure that you add them to the `routine.php` config file.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpg%2Froutine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpg%2Froutine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpg%2Froutine/lists"}