icanboogie / routing
Request routing
Requires
- php: >=8.2
- ext-json: *
- icanboogie/http: ^6.0
Requires (Dev)
- olvlvl/phpunit-given: ^11.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.4
- psr/container: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The icanboogie/routing package handles URL rewriting in native PHP. A Request is mapped to a Route, which in turn is mapped to a Responder. If the process is successful a response is returned. Events are emitted along the way to allow listeners to alter the request or the response, or recover from failure.
The following example is an overview of request processing. The routing components are part of the stack of responder providers.
<?php namespace ICanBoogie\HTTP; /* @var ResponderProvider $responder_provider */ // The request is usually created from the $_SERVER super global. $request = Request::from($_SERVER); // The Responder Provider matches a request with a Responder $responder = $responder_provider->responder_for_request($request); // The Responder responds to the request with a Response, it might also throw an exception. $response = $responder->respond($request); // The response is sent to the client. $response();
Installation
composer require icanboogie/routing
Documentation
New to the package? Follow Getting started. The full index is in docs/.
- Routes: Route patterns · Defining routes · Route providers · URL generation
- Handling requests: Using the Router · Responding to a request · Action responders · Middleware and events
- Controllers: Stateless controllers · Controllers · Action controllers
- Reference: Exceptions
Continuous Integration
The project is continuously tested by GitHub Actions.
Code of Conduct
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.
Contributing
See CONTRIBUTING for details.