{"id":16673558,"url":"https://github.com/sasa-b/router","last_synced_at":"2025-03-13T02:20:28.976Z","repository":{"id":62540388,"uuid":"105814318","full_name":"sasa-b/router","owner":"sasa-b","description":"Lightweight router inspired by Laravel's and Phalcon's router.","archived":false,"fork":false,"pushed_at":"2017-10-09T18:55:44.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T19:20:06.184Z","etag":null,"topics":["dispatcher","library","php","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/sasa-b.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-10-04T20:20:31.000Z","updated_at":"2019-09-02T19:26:37.000Z","dependencies_parsed_at":"2022-11-02T16:00:39.936Z","dependency_job_id":null,"html_url":"https://github.com/sasa-b/router","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-b%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-b%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-b%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-b%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sasa-b","download_url":"https://codeload.github.com/sasa-b/router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243325025,"owners_count":20273203,"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":["dispatcher","library","php","router"],"created_at":"2024-10-12T12:27:12.590Z","updated_at":"2025-03-13T02:20:28.943Z","avatar_url":"https://github.com/sasa-b.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Router\nLightweight router inspired by Laravel's and Phalcon's router.\n*********\n## Usage examples\n```php\n$router = new \\Foundation\\Routing\\Router();\n\n$r-\u003eget('/foo', function () {\n    echo 'Hello foo!';\n});\n\n// here we are utilising cache for performance, if the cache file was not found \n// routes will be registered and the cache file recreated\n$router-\u003ecache(function (\\Foundation\\Routing\\Router $r) {\n    // if you want to collect routes from a file\n    // you can set the path to the routes file as a paramater to collectRoutes() method\n    // or via setRoutesPath() method\n    $r-\u003ecollectRoutes();\n    \n    // you can both collect routes and add them one by one, they will be merged\n    $r-\u003eget('/foo/{bar}', [\n        'controller' =\u003e 'FooController',\n        'action' =\u003e 'index',\n    ]);\n    \n    $r-\u003epost('/foo/{bar}', 'FooController::store');\n});\n\ntry {\n    // Adding event listeners\n    $router-\u003eaddEventListener('before_match', function(\\Foundation\\Routing\\Router $router) {\n        echo \"before match\";\n    });\n\n    $router-\u003eaddEventListener('after_match', function(\\Foundation\\Routing\\Router $router) {\n        echo \"after match\";\n    });\n\n    $dispatcher = $router-\u003ecatch();\n\n    $dispatcher-\u003edispatch();\n\n} catch (\\Foundation\\Routing\\Exceptions\\NotFoundException $e) {\n    echo $e-\u003egetCode() . \" - Page not found\";\n} catch (\\Foundation\\Routing\\Exceptions\\BadHttpMethodException $e) {\n    echo $e-\u003egetCode() . \" - Bad Http Method\";\n} \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsasa-b%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsasa-b%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsasa-b%2Frouter/lists"}