Download the PHP package ft/just-routes without Composer
On this page you can find all versions of the php package ft/just-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ft/just-routes
More information about ft/just-routes
Files in ft/just-routes
Package just-routes
Short Description A library simply for routing requests. Simple. Light. Fast
License MIT
Informations about the package just-routes
Just Routes
A extremely lightweight, fast and focused PHP library strictly for routing requests. No hassle, no framework required.
Just attributes, plain old PHP, and just routes
Usage
composer require ft/just-routes
- Create controller[s]
- Register controller[s]
- Add optional methods
- Dispatch Request
Create Controllers
-
Annotate your controller with request mapping
- Add routes as methods to controller
Register Controllers
Customize
You can customize a few control flow patterns:
- Exceptions
- Not Found Paths
Exceptions
You can catch exceptions at the controller layer or globally via RouteFactory
scoped exception handling via controller annotation
globally catching exceptions
Not Found
globally handle
The End
That's it to get routing configured. Now simply dispatch the request
Miscellaneous
Semantic Attributes
-
[GetMapping]
-
[PutMapping]
-
[PostMapping]
-
[DeleteMapping]
Other Attributes
-
[RequestMapping]
-
[ExceptionHandler]
-
[RequestParam] - Inject a request parameter directly as a method parameter
-
[RequestHeader] - Inject a header directly as a method parameter
Route Syntax
Routes are separated by /
, must start with /
and must not duplicate for HTTP method types
Routes may contain path variables. A path variable is encapsulated by {}
curly braces.
Routes with path variables must have parameters in the route method signature
For example: