mrferos / expressive-http-method
Installs: 1 961
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-11-06 09:57:44 UTC
README
Small utility that routes to methods named after HTTP verbs to help make API development easier.
Installation
Using composer!
composer install mrferos/expressive-method
Usage
Example action:
<?php namespace App\Action; use MrfExpressive\HttpMethodTrait; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; class AcmeAction { use HttpMethodTrait; /** * For GET method * * @param ServerRequestInterface $request * @param ResponseInterface $response * @param callable|null $next * @return mixed */ public function get(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { // Do anything here you normally would! } }
That's it!
There is also an interface MrfExpressive\HttpMethodInterface
that defines methods for all the HTTP verbs.