{"id":18452234,"url":"https://github.com/gregdel/php-router","last_synced_at":"2025-10-15T02:35:19.600Z","repository":{"id":4793771,"uuid":"5946502","full_name":"gregdel/php-router","owner":"gregdel","description":"Simple RESTful php router (no longer maintained)","archived":false,"fork":false,"pushed_at":"2012-09-25T12:41:45.000Z","size":100,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T02:37:48.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kennylee26/ik-expression","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregdel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-25T07:36:29.000Z","updated_at":"2022-12-07T09:51:48.000Z","dependencies_parsed_at":"2022-08-20T21:50:58.756Z","dependency_job_id":null,"html_url":"https://github.com/gregdel/php-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gregdel/php-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregdel%2Fphp-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregdel%2Fphp-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregdel%2Fphp-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregdel%2Fphp-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregdel","download_url":"https://codeload.github.com/gregdel/php-router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregdel%2Fphp-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279036400,"owners_count":26089875,"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","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"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":"2024-11-06T07:30:21.378Z","updated_at":"2025-10-15T02:35:19.581Z","avatar_url":"https://github.com/gregdel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-router\n****\n\nSimple RESTful php router inpired by Slim framework\n\n# Files\n* .htaccess - Redirect everything to the app\n* input.php - The HTTP headers and start the app\n* API/api.php - The API with all the routes\n* API/router.php - Router class\n* API/route.php - Route class\n\nTo add features to the app, you only have to edit the `api` file.\n\n# Add a route\n\trouter = new router();\n\trouter-\u003eaddRoute(@method, @pattern, [@optional_functions], @function);\n\trouter-\u003erun();\n\t\n## Method\nThe method is a string.\nIt should be GET, POST, PUT, DELETE\n\n## Pattern\nYou can do simple things like getting a page :\n\n\t$router-\u003eaddRoute('GET', '/', function() {\n    \theader('Location: index.html');\n\t});\n\nYou can use arguments : \n\n\t$router-\u003eaddRoute('GET', '/info/:day/:month/:year', function($day,$month,$year) {\n    \techo \"Infos for $day/$month/$year\";\n   \t});\n   \t\n## Optional functions\nYou can add optional function, to check authentication for exemple.\n\n\tfunction hello() { echo \"Hello \"; } \n    function world() { echo \"world \"; } \n    $router-\u003eaddRoute('GET', '/helloworld' , hello(), world(), function() {\n    \techo \"!\";\n    }); \n\n# Main function\nYou can do basic stuff as showned before. You can also use objects:\n\n\t$router-\u003eaddRoute('GET', '/datas', function() use ($db, $message, $session) {\n    \t$entries = $db-\u003elastestEntries($session-\u003egetUserid());\n    \t$message-\u003esetData($entries);\n    \t$message-\u003esend();\n\t});\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregdel%2Fphp-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregdel%2Fphp-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregdel%2Fphp-router/lists"}