{"id":13684303,"url":"https://github.com/makallio85/yaml-route","last_synced_at":"2026-01-14T01:11:00.011Z","repository":{"id":62522844,"uuid":"48813380","full_name":"makallio85/yaml-route","owner":"makallio85","description":"Yaml-route provides possibility to configure CakePHP 3 routes with simple yaml files.","archived":false,"fork":false,"pushed_at":"2023-03-24T15:25:15.000Z","size":75,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T20:33:49.493Z","etag":null,"topics":[],"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/makallio85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2015-12-30T18:11:47.000Z","updated_at":"2020-11-09T22:40:28.000Z","dependencies_parsed_at":"2024-04-10T05:38:29.824Z","dependency_job_id":"7b61e73f-8c7f-4bf2-9b3d-078d0807013e","html_url":"https://github.com/makallio85/yaml-route","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/makallio85/yaml-route","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makallio85%2Fyaml-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makallio85%2Fyaml-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makallio85%2Fyaml-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makallio85%2Fyaml-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makallio85","download_url":"https://codeload.github.com/makallio85/yaml-route/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makallio85%2Fyaml-route/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-08-02T14:00:32.059Z","updated_at":"2026-01-14T01:10:59.980Z","avatar_url":"https://github.com/makallio85.png","language":"PHP","funding_links":[],"categories":["Libs"],"sub_categories":[],"readme":"Yaml-route\n----------\n[![Latest Stable Version](https://poser.pugx.org/makallio85/yaml-route/v/stable)](https://packagist.org/packages/makallio85/yaml-route) [![Total Downloads](https://poser.pugx.org/makallio85/yaml-route/downloads)](https://packagist.org/packages/makallio85/yaml-route) [![Latest Unstable Version](https://poser.pugx.org/makallio85/yaml-route/v/unstable)](https://packagist.org/packages/makallio85/yaml-route) [![License](https://poser.pugx.org/makallio85/yaml-route/license)](https://packagist.org/packages/makallio85/yaml-route) [![Build Status](https://travis-ci.org/makallio85/yaml-route.svg?branch=master)](https://travis-ci.org/makallio85/yaml-route) [![Coverage Status](https://coveralls.io/repos/makallio85/yaml-route/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/makallio85/yaml-route?branch=master)\n\nYaml-route provides possibility to configure CakePHP 3 routes with simple YAML files. This is basically just wrapper for CakePHP core routing that parses YAML files and makes proper calls to ```Cake\\Core\\Router```.\n\nMain goal is not to implement all fancy features that CakePHP 3 routing provides, only those ones that are really needed. Of course this is relative to developer, so feel free to fork and commit your own code.\n\n### Installation ###\n\n```composer require makallio85/yaml-route```\n\n### Usage ###\n\n1. Replace all contents in ```config/routes.php``` file with single method call ```makallio85\\YamlRoute\\Generator::getInstance()-\u003erun()```\n2. Load all plugins by calling ```makallio85\\YamlRoute\\Plugin::getInstance()-\u003eload($plugin, $options)```  Method is basically just wrapper for ```Cake\\Core\\Plugin::load()``` method. Note that ```Cake\\Core\\Plugin::loadAll()``` method is not supported and all plugins should be loaded one at time.\n3. Add your own route to ```routes.yml``` files to your project and desired plugins.\n\n### About route configuration ###\n\nEvery route is automatically named with its key. Root route should be named as root by convention.\nRoute can contain path and config keys. Path is always string but config can be string that references to another YAML file that contains routes configuration. Syntax for external path is \"PluginName.RouteFileNameWithoutExtension\". All route configurations should be placed in config folder of project or plugin.\n\nRoute can also contain subroutes and they are defined inside ```config.routes``` key\n\n```config``` key can contain keys listed below\n\n| Key        | Type            | Description                   |\n|:-----------|:----------------|:------------------------------|\n| controller | string          | Route controller              |\n| action     | string          | Route action                  |\n| plugin     | string          | Route plugin                  |\n| _method    | array or string | Route method                  |\n| extensions | array           | Allowed extensions            |\n| routes     | array           | Subroutes                     |\n| validate   | array           | List of variables to validate |\n\nNote that subroutes can't contain routes so ```config.routes``` for subroutes is not available.\n\n### Examples ###\n\n##### Basic routing #####\n```config/routes.yml``` like this\n```\nroot:\n  path: /\n```\n\nTurns into this\n\n```php\n\\Cake\\Routing\\Router::scope('/', [], function ($routes) {\n\t$routes-\u003efallbacks('DashedRoute');\n});\n\n\\Cake\\Core\\Plugin::routes();\n```\n\n##### Plugin Routing #####\n\n```plugins/PluginCars/config/routes.yml``` like this\n\n```\ncars:\n  path: /cars\n  config:\n    plugin: PluginCars\n    controller: Cars\n    action: index\n    extensions:\n      - json\n      - xml\n    routes:\n      bmws_list:\n        path: /bmws\n        config:\n          controller: Bmws\n      bmws_view:\n        path: /bmws/{id}\n        config:\n          _method: GET\n          controller: Bmws\n          action: view\n          validate:\n            id: '[0-9]+'\n      bmws_add:\n        path: /bmws/add\n        config:\n          _method: POST\n          controller: Bmws\n          action: add\n      ladas:\n        path: /ladas\n        config:\n          controller: Ladas\n```\n\nTurns into this\n\n```php\n\\Cake\\Routing\\Router::plugin('PluginCars', ['path' =\u003e '/cars'], function ($routes) {\n  $routes-\u003eextensions(['0' =\u003e 'json', '1' =\u003e 'xml']);\n  $routes-\u003econnect('/', ['plugin' =\u003e 'PluginCars', 'controller' =\u003e 'Cars', 'action' =\u003e 'index'], ['_name' =\u003e 'cars']);\n  $routes-\u003econnect('/bmws', ['controller' =\u003e 'Bmws'], ['_name' =\u003e 'bmws_list']);\n  $routes-\u003econnect('/bmws/:id', ['_method' =\u003e 'GET', 'controller' =\u003e 'Bmws', 'action' =\u003e 'view'], ['_name' =\u003e 'bmws_view', 'pass' =\u003e ['0' =\u003e 'id'], 'id' =\u003e '[0-9]+']);\n  $routes-\u003econnect('/bmws/add', ['_method' =\u003e 'POST', 'controller' =\u003e 'Bmws', 'action' =\u003e 'add'], ['_name' =\u003e 'bmws_add']);\n  $routes-\u003econnect('/ladas', ['controller' =\u003e 'Ladas'], ['_name' =\u003e 'ladas']);\n  $routes-\u003efallbacks('DashedRoute');\n});\n\n\\Cake\\Core\\Plugin::routes();\n```\n\n### Debugging ###\n\nIf you want to debug generated routes, you can set debug parameter to true when calling ```makallio85\\YamlRoute\\Generator::getInstance()-\u003erun(true)```.\nAfter that, you are able to get executed calls by calling ```makallio85\\YamlRoute\\Generator::getInstance()-\u003egetDump()```.\n\n### toDo ###\n\n- Add support for true inheritance by allowing subroute to contain subroute\n- ~~Add tests~~ Add more tests\n- Refactor classes\n- ~~Add support for extensions~~\n- ~~Improve exception handling~~\n\n### License ###\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 makallio85\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakallio85%2Fyaml-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakallio85%2Fyaml-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakallio85%2Fyaml-route/lists"}