{"id":17474157,"url":"https://github.com/ghostffcode/phoutes","last_synced_at":"2025-06-29T17:37:43.238Z","repository":{"id":81383651,"uuid":"62175294","full_name":"ghostffcode/phoutes","owner":"ghostffcode","description":"Simple PHP routes Handler","archived":false,"fork":false,"pushed_at":"2016-07-23T15:09:58.000Z","size":24,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T20:48:39.661Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://phoutes.herokuapp.com/","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/ghostffcode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-28T21:24:32.000Z","updated_at":"2020-10-08T23:43:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bb6e0b8-12b1-4958-a399-2d7b700a563b","html_url":"https://github.com/ghostffcode/phoutes","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"3c9c376bba78268fde5f640d90af45a0d1b8132a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ghostffcode/phoutes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Fphoutes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Fphoutes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Fphoutes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Fphoutes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostffcode","download_url":"https://codeload.github.com/ghostffcode/phoutes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Fphoutes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262639178,"owners_count":23341437,"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":[],"created_at":"2024-10-18T18:08:36.024Z","updated_at":"2025-06-29T17:37:43.211Z","avatar_url":"https://github.com/ghostffcode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phoutes - Simple PHP routes Handler\n\n![Phoutes - Simple PHP Routes Handler](http://i.imgur.com/VFyGWi0.png)\n\n##How to run:\n\nclone the script:\n\n```bash\ngit clone https://github.com/ghostffcode/phoutes.git\n```\nAnd navigate to the public directory in the phoutes folder with your browser, mine is:\n\n```bash\nhttp://localhost/phoutes/public\n```\n* You might want to create a virtual host in your dev environment for the css and javascript files to be loaded.\n\n## Adding Route Handler\nopen phoutes/App/routes.php in your favorite code editor and create a new route using:\n\n```php\n// get route handler\n$route-\u003eget('/home', function() {\n echo \"I got Home\";\n});\n\n// post route handler\n$route-\u003epost('/home', function() {\n echo \"I got a post request\";\n});\n\n// update route handler\n$route-\u003eupdate('/home', function() {\n echo \"I got an update request\";\n});\n\n// delete route handler\n$route-\u003epost('/home', function() {\n echo \"I got a delete request\";\n});\n\n// all route handler, for any request type\n$route-\u003eall('/home', function() {\n echo \"I can handle all request types\";\n});\n```\n\n## To handle url variables:\n```php\n// the variable in the url is :user\n$route-\u003eget('/user/:user/', function($user) {\n  echo $user;\n});\n```\n\ntry it out visit:\n```bash\nhttp://localhost/phoutes/public/user/Bliss\n```\nThe page echoes out:\nBliss\n\n## Using Controllers in routes\nYou can add a new controller in phoutes/App/Controllers/ directory (name of controller needs to match the controller class name)\n\nTo use a controller, prefix the class instance name with 'ctrl'\n\n```php\n// create a get route that take a url variable user and passes it to the Profile controller\n$route-\u003eget('/:user/', function($user) {\n  // sample use of a controller\n $profile = new ctrlProfile();\n $profile-\u003ename($user);\n});\n```\n\n## Rendering a view file\nThe view directory is \"Phoutes/App/Views/\"\nYou can place your html or php files in that directory\n\nTo render a view file in your code, use\n```php\nview::render($filename, $data);\n```\n\nThe static view method, takes two arguments:\n* The first is the view file name Eg. index or user/profile (Default is index).\n* The second (optional) is the data to be passed into the view file.\n\nExample of rendering a view file:\n```php\n$route-\u003eall('/', function () {\n  view::render('profile');  // renders profile.php file\n});\n```\n\n## Fixes\n* v1.1\n  - The arguments of a callback function of a route with route Parameters can be in any order.\n\n## Want to Help?\nThank you for trying to out, if there is something you will like to add, do make a pull request.\n\nDon't forget to star this!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostffcode%2Fphoutes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostffcode%2Fphoutes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostffcode%2Fphoutes/lists"}