{"id":20645991,"url":"https://github.com/jakecyr/php-simple-routing","last_synced_at":"2025-10-07T06:18:06.497Z","repository":{"id":114277604,"uuid":"140308656","full_name":"jakecyr/PHP-Simple-Routing","owner":"jakecyr","description":null,"archived":false,"fork":false,"pushed_at":"2019-08-01T12:55:00.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-09T15:57:27.534Z","etag":null,"topics":["php","rest-api","routing"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakecyr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-09T15:55:02.000Z","updated_at":"2023-07-20T23:09:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"375475ff-7b88-4329-b728-d0b4780ca698","html_url":"https://github.com/jakecyr/PHP-Simple-Routing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jakecyr/PHP-Simple-Routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakecyr%2FPHP-Simple-Routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakecyr%2FPHP-Simple-Routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakecyr%2FPHP-Simple-Routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakecyr%2FPHP-Simple-Routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakecyr","download_url":"https://codeload.github.com/jakecyr/PHP-Simple-Routing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakecyr%2FPHP-Simple-Routing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288454,"owners_count":22986663,"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":["php","rest-api","routing"],"created_at":"2024-11-16T16:22:56.953Z","updated_at":"2025-10-07T06:18:01.457Z","avatar_url":"https://github.com/jakecyr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Simple Routing\nSimple PHP routing library similar to JavaScript Express.\n\n## Setup\nClone or download this repo and add the folder to your project. Require the \"init.php\" file to include all dependencies.\n\nAllows for either request payload or parameters. \n\nUse Database class from the repo below if required and pass reference to the RouteManager instance upon creation:\n[https://github.com/jakecyr/PhpDatabase](https://github.com/jakecyr/PhpDatabase)\n\nCreate a route for each type of endpoint:\n```\n$route = new Route();\n\n$route\n\t-\u003euse(function($req, $res, $db){\n\t\t//middleware\n\t})\n\t-\u003eget('all', function($req, $res){\n\t\t$res-\u003eend(\"All employees here\");\n\t})\n\t-\u003eget('one', function($req, $res){\n\t\tif(!isset($params-\u003equery[\"employee_id\"])) new JsonError('Employee ID required');\n\t\t\n\t\t$res-\u003ejson([\n\t\t\t\"Employee ID\" =\u003e $params-\u003equery[\"employee_id\"]\n\t\t]);\n\t})\n\t-\u003epost('add', function($req, $res, $db){\n\t\t$result = $db-\u003eexecute(\"INSERT INTO User(name, age) VALUES ('Test', 20)\");\n\t\t$res-\u003ejson($result);\n\t});\n```\n\nCreate a route manager and add the routes:\n```\n$routeManager = new RouteManager($dbConnection);\n\n$routeManager\n\t-\u003euse('employees', require('routes/employees.php')\n\t-\u003euse('schedule', require('routes/schedule.php')\n\t-\u003ehandleRoute();\n```\nExample endpoint URL:\n...ajax.php?route=employees\u0026path=one\u0026employee_id=######\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakecyr%2Fphp-simple-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakecyr%2Fphp-simple-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakecyr%2Fphp-simple-routing/lists"}