{"id":22576984,"url":"https://github.com/eylmz/router","last_synced_at":"2025-04-10T17:14:35.519Z","repository":{"id":62503361,"uuid":"100676771","full_name":"eylmz/Router","owner":"eylmz","description":"Router - Fast, flexible routing for PHP, enabling you to quickly and easily build RESTful web applications.","archived":false,"fork":false,"pushed_at":"2017-08-19T07:35:44.000Z","size":21,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T15:01:54.777Z","etag":null,"topics":["mvc","oop","php","router"],"latest_commit_sha":null,"homepage":"http://emre.pw","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/eylmz.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-08-18T05:40:00.000Z","updated_at":"2023-09-02T21:30:09.000Z","dependencies_parsed_at":"2022-11-02T10:01:21.977Z","dependency_job_id":null,"html_url":"https://github.com/eylmz/Router","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eylmz%2FRouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eylmz%2FRouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eylmz%2FRouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eylmz%2FRouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eylmz","download_url":"https://codeload.github.com/eylmz/Router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261916,"owners_count":21074225,"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":["mvc","oop","php","router"],"created_at":"2024-12-08T04:10:44.494Z","updated_at":"2025-04-10T17:14:35.499Z","avatar_url":"https://github.com/eylmz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Router\nRouter - Fast, flexible routing for PHP, enabling you to quickly and easily build RESTful web applications.\u003cbr\u003e\nVersion : 1.0.0\n* [Installation](#installation)\n* [Simple Usage](#simple-usage)\n* [Available Router Methods](#available-router-methods)\n* [Route Parameters](#route-parameters)\n* [Controller and Method Parameters](#controller-and-method-parameters)\n* [Regular Expression Constraints](#regular-expression-constraints)\n* [Named Routes](#named-routes)\n* [Route Groups](#route-groups)\n* [License](#license)\n___\n### Installation\nYou can download it and using it without any changes.\n\nOR use Composer.\n\nIt's recommended that you use Composer to install Route.\n```\n$ composer require eylmz/router\n```\n___\n### Simple Usage \n#### .htaccess\n```\nOptions -Indexes\nOptions -MultiViews\nRewriteEngine On\n\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^(.+)$ index.php?url=$1 [QSA,L]\n``` \n\n#### index.php\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n// or\n// require 'src/eylmz/Router.php';\n\nuse eylmz/Router/Router;\n\nRouter::setControllerNamespace(\"App\\\\Controllers\\\\\");\nRouter::setMiddlewareNamespace(\"App\\\\Middlewares\\\\\");\n\n// Routers\nRouter::any(\"/url\",\"Controller@Method\");\n// or\nRouter::any(\"/url2\",function() {\n\n});\n// #Routers\n\nRouter::routeNow(@$_GET[\"url\"]);\n```\n___\n### Available Router Methods\n```php\nRouter::get($url, $callback);\nRouter::post($url, $callback);\nRouter::put($url, $callback);\nRouter::patch($url, $callback);\nRouter::delete($url, $callback);\nRouter::options($url, $callback);\n```\n\n#### Usage More Than One Routers\n```php\nRouter::match(\"GET|POST\",$url,$callback);\n//or\nRouter::match([\"GET\",\"POST\"],$url,$callback);\n```\n#### Usage The Any Methods\n```php\nRouter::any($url,$callback);\n``` \n___\n### Route Parameters\n#### Required Parameters\n```php\nRouter::get(\"url\\{id}\",function($myID){\n  echo \"Hello \" . $myID;\n});\n```\n\n#### Optional Parameters\n```php\nRouter::get(\"url\\{id?}\",function($myID=0){\n  echo $myID;\n});\n```\n___\n### Controller and Method Parameters\n```php \n// Controller -\u003e First Parameter\n// Method -\u003e Second Parameter\nRouter::get(\"admin\\{controller}\\{method}\",\"{?}@{?}\");\n\n// or\n\n// Custom\nRouter::get(\"admin\\{method}\\{controller}\",\"{controller}@{method}\");\n\n```\n___\n### Regular Expression Constraints\n```php\nRouter::get('url/{id}', function ($myID) {\n    \n})-\u003ewhere('id', '[0-9]+');\n\nRouter::get('user/{id}/{name}', function ($myID, $name) {\n    \n})-\u003ewhere(['id' =\u003e '[0-9]+', 'name' =\u003e '[a-zA-Z]+']);\n```\n___\n### Named Routes\n```php\nRouter::get('user/profile', function () {\n    //\n})-\u003ename('profile');\n```\n\n#### Generating URLs To Named Routes\n```php\n$url = Router::route(\"profile\");\n\n// Usage with parameters\nRouter::get('url/{id}/profile', function ($id) {\n    \n})-\u003ename('profile');\n\n$url = Router::route('profile', ['id' =\u003e 1]);\n```\n___\n### Route Groups\n#### Prefix URL\n```php \nRouter::prefix('admin')-\u003egroup(function () {\n    Router::get('users', function () {\n        // new url -\u003e /admin/users\n    });\n});\n```\n\n#### Middleware\n```php\nRouter::middleware(\"middleware\")-\u003egroup(function () {\n    Router::get('/', function () {\n        \n    });\n\n    Router::get('url/profile', function () {\n        \n    });\n});\n```\n\n#### Usage More Than One Middlewares\n```php\nRouter::middleware([\"middleware\",\"middleware2\"])-\u003egroup(function () {\n    Router::get('/', function () {\n        \n    });\n\n    Router::get('url/profile', function () {\n        \n    });\n});\n```\n___\n### License\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feylmz%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feylmz%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feylmz%2Frouter/lists"}