Download the PHP package fredemmott/hack-router without Composer
On this page you can find all versions of the php package fredemmott/hack-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fredemmott/hack-router
More information about fredemmott/hack-router
Files in fredemmott/hack-router
Package hack-router
Short Description URI routing for Hack
License
Homepage https://github.com/fredemmott/hack-router
Informations about the package hack-router
Hack-Router 
Fast, type-safe request routing, parameter retrieval, and link generation, with PSR-7 support.
Components
HTTP Exceptions
Exception classes representing common situations in HTTP applications:
InternalServerError
MethodNotAllowed
NotFoundException
BaseRouter
A simple typed request router. Example:
Simplified for conciseness - see
examples/BaseRouterExample.php
for
full executable example.
UriPatterns
Generate FastRoute fragments, URIs (for linking), and retrieve URI parameters in a consistent and type-safe way:
Parameters can be retrevied, with types checked at runtime both against the values, and the definition:
You can also generate links to controllers:
These examples are simplified for conciseness - see
examples/UriPatternsExample.php
for
full executable example.
Codegen
The hhvm/hack-router-codegen project builds on top of of this project to automatically generate:
- Full request routing objects and URI maps based on UriPatterns defined in the controllers
- Per-controller parameter classes, allowing
$params->getFoo()
instead of$params->getString('Foo')
; this allows the typechecker to catch more errors, and IDE autocomplete functionality to support parameters. - Per-controller UriBuilder classes, with similar benefits
Contributing
We welcome GitHub issues and pull requests - please see CONTRIBUTING.md for details.
License
hack-router is MIT-licensed.