{"id":37265849,"url":"https://github.com/cherry-framework/router","last_synced_at":"2026-01-16T00:17:08.095Z","repository":{"id":62501548,"uuid":"174018178","full_name":"cherry-framework/router","owner":"cherry-framework","description":"Cherry-project Router","archived":false,"fork":false,"pushed_at":"2019-05-04T15:23:53.000Z","size":24,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T15:49:10.404Z","etag":null,"topics":["cherry","composer","router"],"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/cherry-framework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-05T20:47:05.000Z","updated_at":"2019-05-04T15:23:09.000Z","dependencies_parsed_at":"2022-11-02T12:01:27.164Z","dependency_job_id":null,"html_url":"https://github.com/cherry-framework/router","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cherry-framework/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-framework%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-framework%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-framework%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-framework%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cherry-framework","download_url":"https://codeload.github.com/cherry-framework/router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-framework%2Frouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28474499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T00:15:39.755Z","status":"ssl_error","status_checked_at":"2026-01-16T00:15:32.174Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["cherry","composer","router"],"created_at":"2026-01-16T00:17:07.331Z","updated_at":"2026-01-16T00:17:08.088Z","avatar_url":"https://github.com/cherry-framework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cherry-Router\nThe Cherry-project Router\n\n[![GitHub license](https://img.shields.io/github/license/abgeo07/cherry-router.svg)](https://github.com/ABGEO07/cherry-router/blob/master/LICENSE)\n\n[![GitHub release](https://img.shields.io/github/release/abgeo07/cherry-router.svg)](https://github.com/ABGEO07/cherry-router/releases)\n\n[![Packagist Version](https://img.shields.io/packagist/v/cherry-project/router.svg \"Packagist Version\")](https://packagist.org/packages/cherry-project/router \"Packagist Version\")\n\n------------\n\n## Including\n**Install from composer** `composer require cherry-project/router`\n\n**Include Autoloader in your main file** (Ex.: index.php)\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\n```\n\nDefine application root directory\n```php\ndefine('__ROOT__', __DIR__);\n```\n\nIn your application you must have **config.json** file for storing app configuration settings and you must define his location:\n```php\ndefine('CONFIG_FILE', __DIR__ . '/config/config.json');\n```\n\n**config.json** must contain path to **routes.json** and controllers directory\n\n```json\n{\n    \"ROUTES_FILE\": \"config/routes.json\",\n    \"CONTROLLERS_PATH\": \"controllers\"\n}\n```\n\nGet app config parameters and define it:\n\n```php\n$config = file_get_contents(CONFIG_FILE)\n    or die(\"Unable to open config file!\");\n\n$config = json_decode($config, 1);\n\nforeach ($config as $k =\u003e $v)\n    define($k, __DIR__ . '/' . $v);\n```\n\n**Notice**: This approach will be replaced in the new version :))\n\nIt's time to configure routes file \n\nThe routes file is a json file, where object key is route unique name. \n\nEach route must have **path**, **method** and **action** keys. Homepage route example:\n```json\n{\n  \"homepage\": {\n      \"path\": \"/\",\n      \"method\": \"GET\",\n      \"action\": \"DefaultController::index\"\n  }\n}\n```\n\n**Router file basic structure**\n```json\n{\n    \"[RouteName]\": {\n        \"path\": \"[URL]\",\n        \"method\": \"[HTTP_Method]\",\n        \"action\": \"[Controller]::[Method]\"\n    }\n}\n```\n\nDefinitions for router keys:\n- **[RouteName]** - Route unique name;\n- **path** - Route url. (Ex.: For address http://www.example.com/homepage [URL] is *homepage*);\n- **method** - Route HTTP Method. Allowed all [HTTP methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods \"HTTP methods\");\n- **action** - Route callback action. The firs part of action (before *::*) is your controller (stored in **CONTROLLERS_PATH**).\nController is a simple [PHP Class](http://php.net/manual/en/language.oop5.php \"PHP Class\") where\n[Controller] is Class name (Class name and class filename must have same names (Ex.: **[Controller].php**)).\nThe second part of action key (after ::) is controllers (class) public method;\n\nYour route path can use **Placeholders**. Placeholder is a template of your route.\n\nRoute example with placeholder:\n```json\n{\n    \"homepage\": {\n        \"path\": \"/hello/{name}\",\n        \"method\": \"GET\",\n        \"action\": \"DefaultController::sayHello\"\n    }\n}\n```\n\nThere we have placeholder called **{name}** and we can get this value in controller:\n```php\npublic function sayHello($name)\n{\n    echo \"Hello, {$name}\";\n}\n```\n\n**2019 \u0026copy; Cherry-project**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry-framework%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcherry-framework%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry-framework%2Frouter/lists"}