apitte/middlewares

This package is abandoned and no longer maintained. The author suggests using the contributte/apitte package instead.

Middlewares support for Apitte stack

Installs: 315 124

Dependents: 1

Suggesters: 0

Security: 0

Stars: 7

Watchers: 3

Forks: 3

Open Issues: 0

pkg:composer/apitte/middlewares

v0.8.0 2021-09-07 15:18 UTC

This package is auto-updated.

Last update: 2025-12-09 12:22:46 UTC


README

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

Disclaimer

⚠️ This project is no longer being maintained. Please use contributte/apitte.
Composer apitte/middlewares
Version
PHP
License

Usage

To install the latest version of apitte/middlewares use Composer.

composer require apitte/middlewares

Documentation

Middlewares for Apitte.

Transform and validate request or early return response before it is handled by dispatcher.

Setup

First of all, setup core and contributte/middlewares packages.

Install and register middlewares plugin

composer require apitte/middlewares
api:
    plugins:
        Apitte\Middlewares\DI\MiddlewaresPlugin:

In index.php replace Apitte\Core\Application\IApplication with Contributte\Middlewares\Application\IApplication.

Configuration

TracyMiddleware (with priority 100) and AutoBasePathMiddleware (with priority 200) are registered by default, but you could disable them if you want.

api:
    plugins:
        Apitte\Middlewares\DI\MiddlewaresPlugin:
            tracy: true
            autobasepath: true

Apitte\Middlewares\ApiMiddleware which run whole Apitte application is registered with priority 500. Make sure there is no middleware with higher priority.

Middlewares

If you want to add another middleware, just register a class with appropriate tags.

services:
    m1:
        factory: App\Api\Middleware\ExampleMiddleware
        tags: [middleware: [priority: 10]]
namespace App\Api\Middleware;

use Contributte\Middlewares\IMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class ExampleMiddleware implements IMiddleware
{

    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
    {
    	// Call next middleware in a row
        $response = $next($request, $response);
        // Return response
        return $response;
    }

}

See contributte/middlewares documentation for more info and useful middlewares

Versions

State Version Branch Nette PHP
stable ^0.8 master 3.0+ >=7.3
stable ^0.5 master 2.4 >=7.1

Development

This package was maintained by these authors.

Consider to support contributte development team. Also thank you for using this package.