nia / routing-facade-http
HTTP routing facade to simply add HTTP routes to a given router.
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.1.0
2017-04-12 20:23 UTC
Requires
- php: >=7.0.0
- nia/requestresponse-http: *
- nia/routing: *
This package is not auto-updated.
Last update: 2022-03-09 07:21:45 UTC
README
HTTP routing facade to simply add HTTP routes to a given router.
Installation
Require this package with Composer.
composer require nia/routing-facade-http
Tests
To run the unit test use the following command:
$ cd /path/to/nia/component/
$ phpunit --bootstrap=vendor/autoload.php tests/
How to use
The following sample shows you how to use the HTTP routing facade component for a common use case.
$router = new Router(); // encapsulate the router into the facade. $facade = new HttpFacade($router); // simple rest handling. $facade->get('#^/articles/$#', $articleListHandler); $facade->put('#^/articles/$#', $articleUpdateHandler); $facade->post('#^/articles/$#', $articleCreateHandler); // routes with additional conditions and filters. $facade->get('#^/bookmarks/$#', $bookmarkListHandler, $myCondition, $myFilter); $facade->put('#^/bookmarks/$#', $bookmarkUpdateHandler, $myCondition, $myFilter); $facade->post('#^/bookmarks/$#', $bookmarkCreateHandler, $myCondition, $myFilter);