{"id":15525382,"url":"https://github.com/ghostwriter/router","last_synced_at":"2025-03-20T04:08:36.777Z","repository":{"id":200127603,"uuid":"704876564","full_name":"ghostwriter/router","owner":"ghostwriter","description":"[WIP] Router implementation for PHP","archived":false,"fork":false,"pushed_at":"2024-07-15T01:08:24.000Z","size":47,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-20T07:32:52.291Z","etag":null,"topics":["ghostwriter","router"],"latest_commit_sha":null,"homepage":"https://github.com/ghostwriter/router","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostwriter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null},"funding":{"github":["ghostwriter"]}},"created_at":"2023-10-14T11:22:13.000Z","updated_at":"2024-07-15T01:08:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"f52e218a-23a4-4ba1-a78d-20b563359fb1","html_url":"https://github.com/ghostwriter/router","commit_stats":null,"previous_names":["ghostwriter/router"],"tags_count":0,"template":false,"template_full_name":"ghostwriter/wip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226293440,"owners_count":17601740,"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":["ghostwriter","router"],"created_at":"2024-10-02T10:57:13.726Z","updated_at":"2024-11-25T07:52:50.899Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","readme":"# router\n\n[![Compliance](https://github.com/ghostwriter/router/actions/workflows/compliance.yml/badge.svg)](https://github.com/ghostwriter/router/actions/workflows/compliance.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/router?color=8892bf)](https://www.php.net/supported-versions)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/router\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Code Coverage](https://codecov.io/gh/ghostwriter/router/branch/main/graph/badge.svg)](https://codecov.io/gh/ghostwriter/router)\n[![Type Coverage](https://shepherd.dev/github/ghostwriter/router/coverage.svg)](https://shepherd.dev/github/ghostwriter/router)\n[![Psalm Level](https://shepherd.dev/github/ghostwriter/router/level.svg)](https://psalm.dev/docs/running_psalm/error_levels)\n[![Latest Version on Packagist](https://badgen.net/packagist/v/ghostwriter/router)](https://packagist.org/packages/ghostwriter/router)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/router?color=blue)](https://packagist.org/packages/ghostwriter/router)\n\nwork in progress\n\n\u003e **Warning**\n\u003e\n\u003e This project is not finished yet, work in progress.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/router\n```\n\n## Usage\n\n```php\n// work in progress\n\n$middlewares = [\n    ErrorHandlerMiddlewareInterface::class =\u003e ErrorHandlerMiddleware::class,\n];\n\n$route = new Route(['GET','HEAD'], '/', IndexRequestHandler::class, [GuestMiddleware::class], 'home');\n\n$router = new Router($middlewares); // MiddlewareInterface\n\n$router-\u003ewithRoute($route);\n\n$request = new ServerRequest();\n\n$matched = $router-\u003ematch($request); // CurrentRoute/RouteInterface\n\n\n$router-\u003eaddRoute('GET', '/', HomeHandler::class, [GuestMiddleware::class]);\n\n$router-\u003eget('/about', AboutHandler::class, [GuestMiddleware::class]);\n\n$router-\u003eget('/auth/github', GitHubLoginHandler::class, [GuestMiddleware::class], 'auth.login.github');\n\n    // create, read, edit, update, store, delete, view, show \n$router-\u003emiddleware([GuestMiddleware::class], function($router){\n    $router-\u003eget('/auth/login', LoginCreateHandler::class, 'auth.login.create');\n    $router-\u003epost('/auth/login', LoginStoreHandler::class, 'auth.login.store');\n\n    $router-\u003eget('/auth/register', RegisterCreateHandler::class, 'auth.register.create');\n    $router-\u003epost('/auth/register', RegisterStoreHandler::class, 'auth.register.store');\n\n    $router-\u003eget('/posts', PostIndexHandler::class, 'members.index');\n    $router-\u003eget('/posts/{post:id}', PostShowHandler::class, 'members.show');\n});\n\n$router-\u003emiddleware([AuthMiddleware::class], function($router){\n    $router-\u003eget('/users', MembersIndexHandler::class, 'members.index');\n    $router-\u003eget('/users/{member:id}', MemberShowHandler::class, 'members.show');\n\n    $router-\u003eget('/posts/create', PostCreateHandler::class, 'members.create');\n    $router-\u003epost('/posts', PostStoreHandler::class, 'members.store');\n    $router-\u003eget('/posts/{post:id}/edit', PostEditHandler::class, 'members.edit');\n    $router-\u003eput('/posts/{post:id}', PostUpdateHandler::class, 'members.update');\n    $router-\u003edelete('/posts/{post:id}', PostDeleteHandler::class, 'members.delete');\n});\n```\n\n### Changelog\n\nPlease see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.\n\n### Security\n\nIf you discover any security-related issues, please use [`Security Advisories`](https://github.com/ghostwriter/router/security/advisories/new) instead of using the issue tracker.\n\n### Credits\n\n- [Nathanael Esayeas](https://github.com/ghostwriter)\n- [All Contributors](https://github.com/ghostwriter/psalm-plugin/contributors)\n\n### License\n\nThe BSD-3-Clause. Please see [License File](./LICENSE) for more information.\n","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Frouter/lists"}