mrferos/expressive-http-method

There is no license information available for the latest version (2.0.0) of this package.

2.0.0 2015-10-25 02:10 UTC

This package is auto-updated.

Last update: 2024-04-06 08:46:39 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.