odbav-to / presenter-route
This package is abandoned and no longer maintained.
The author suggests using the entrydo/rest-route package instead.
Route for Nette framework that supports single action presenters and HTTP methods.
2.1
2018-01-14 01:06 UTC
Requires
- nette/application: 2.4.*
- nette/di: 2.4.*
- nette/http: 2.4.*
Requires (Dev)
- nette/bootstrap: 2.4.*
- nette/neon: 2.4.*
- nette/utils: 2.4.*
- phpunit/phpunit: ^6.0
This package is not auto-updated.
Last update: 2019-02-20 19:11:09 UTC
README
Routes for Nette single action presenters with HTTP methods support.
Install
Easiest way is by composer composer require odbav-to/presenter-route
You have to register IndependentSingleActionPresenter extension in your config.neon
:
extensions:
- Symplify\SymfonyEventDispatcher\Adapter\Nette\DI\SymfonyEventDispatcherExtension
- Symplify\SymbioticController\DI\IndependentSingleActionPresenterExtension
And you are ready to go :-).
Routes
use OdbavTo\PresenterRoute\Route; use Nette\Application\Routers\RouteList; $router = new RouteList(); $router[] = new Route('/', HomepagePresenter::class);
REST routes
Support for GET
, POST
, PUT
, DELETE
, PATCH
, HEAD
, OPTIONS
HTTP methods.
$router[] = RestRoute::get('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::GET]);
$router[] = new RestRoute::post('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::POST]);
$router[] = new RestRoute::put('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::PUT]);
$router[] = new RestRoute::delete('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::DELETE]);
$router[] = new RestRoute::patch('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::PATCH]);
$router[] = new RestRoute::head('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::HEAD]);
$router[] = new RestRoute::options('/', HomepagePresenter::class); // or $router[] = new Route('/', HomepagePresenter::class, [IRequest::OPTIONS]);
For multiple HTTP methods use Route
and 3rd parameter:
$router[] = new Route('/', HomepagePresenter::class, [IRequest::GET, IRequest::POST, IRequest::DELETE]);