{"id":15412211,"url":"https://github.com/maymeow/cake-attribute-routing","last_synced_at":"2025-03-28T03:15:47.943Z","repository":{"id":46165766,"uuid":"425483352","full_name":"MayMeow/cake-attribute-routing","owner":"MayMeow","description":"🌐 Attribute routing for CakePHP 4.*","archived":false,"fork":false,"pushed_at":"2021-11-09T20:49:04.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-02T04:24:29.987Z","etag":null,"topics":["attributes","cakephp","cakephp-plugin","cakephp4","php8","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/MayMeow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"MayMeow","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-11-07T11:21:43.000Z","updated_at":"2021-11-09T20:51:48.000Z","dependencies_parsed_at":"2022-09-14T13:41:21.721Z","dependency_job_id":null,"html_url":"https://github.com/MayMeow/cake-attribute-routing","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayMeow%2Fcake-attribute-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayMeow%2Fcake-attribute-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayMeow%2Fcake-attribute-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayMeow%2Fcake-attribute-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MayMeow","download_url":"https://codeload.github.com/MayMeow/cake-attribute-routing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960815,"owners_count":20700781,"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":["attributes","cakephp","cakephp-plugin","cakephp4","php8","routing"],"created_at":"2024-10-01T16:51:42.975Z","updated_at":"2025-03-28T03:15:47.894Z","avatar_url":"https://github.com/MayMeow.png","language":"PHP","funding_links":["https://github.com/sponsors/MayMeow"],"categories":[],"sub_categories":[],"readme":"# Attribute Routing plugin for CakePHP\n\nAttribute routing for CakePHP 4.*\n\n## Requirements\n\n- CakePHP 4.x\n- PHP 8.x :warning: This plugin using features that are available in PHP 8 and later.\n- Cache (tested with redis), all routes are cached before can be used.\n\n## Installation\n\nYou can install this plugin into your CakePHP application using [composer](https://getcomposer.org).\n\nThe recommended way to install composer packages is:\n\n```\ncomposer require maymeow/cake-attribute-routing\n```\n\nAnd load it.\n\n```bash\nphp bin/cake.php plugin load MayMeow/Routing\n```\n\n## Configuring\n\nAdd new key `Controllers` somewhere in application configuration and provide\ncontroller names where you want to use Attribute Routes.\n\n```php\n// app_local.php\n'Controllers' =\u003e [\n    \\App\\Controller\\UsersController::class\n]\n```\n\n## Usage\n\nTo define route add attribute `Route` with required path to the methods as follows:\n\n```php\n#[Route('/users')]\npublic function index()\n{\n    $users = $this-\u003epaginate($this-\u003eUsers);\n\n    $this-\u003eset(compact('users'));\n}\n```\n### Wildcard parameters\n\nSometimes you need to pass parameters to your action in that case you can use wildcard route:\n\n```php\n#[Route('/users/edit/*')]\npublic function edit($id = null)\n{\n    $user = $this-\u003eUsers-\u003eget($id, [\n        'contain' =\u003e [],\n    ]);\n    // ...\n}\n```\n\n:warning: If you're creating wildcard route you must define all other routers in sub-path.\n\n### Named parameters\n\nInstead of using wildcard you can use named parameters. This is usable wne you want to pass more than one\nparameter to your controllers' action.\n\n```php\n#[Route('/users/:id/details', options: ['id' =\u003e '\\d+', 'pass' =\u003e ['id']])]\npublic function view($id = null)\n{\n    $user = $this-\u003eUsers-\u003eget($id, [\n        'contain' =\u003e [],\n    ]);\n\n    $this-\u003eset(compact('user'));\n}\n```\n\nWhen you're creating route with named parameter you have to pass options to tell router which parameters\nyou want to pass to controller.\n\nPath to controller action `Controller::action` is generated automatically from\ncontroller class name and method name;\n\n## Troubleshooting\n\nThis plugin using cache for routes: all routes need to be cached before use. If you have problem with\nroutes try to clear cache.\n\nFond bug? Or do you want new feature? Open new Issue https://github.com/MayMeow/cake-attribute-routing/issues\n\nLicense MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaymeow%2Fcake-attribute-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaymeow%2Fcake-attribute-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaymeow%2Fcake-attribute-routing/lists"}