Latest release: v0.4

Apitte/Middlewares

Content

Plugin

This plugin requires Apitte/Core library.

At first you have to register the main extension.

extensions:
    api: Apitte\Core\DI\ApiExtension
1
2

Secondly, add the MiddlewaresPlugin plugin.

api:
    plugins:
        Apitte\Middlewares\DI\MiddlewaresPlugin:
1
2
3

Configuration

You can configure a few options.

api:
    plugins: 
        Apitte\Middlewares\DI\MiddlewaresPlugin:
            tracy: true
            autobasepath: true
1
2
3
4
5
  • tracy - Automatically register Contributte\Middlewares\TracyMiddleware with priority 100.
  • autobasepath - Automatically register Contributte\Middlewares\AutoBasePathMiddleware with priority 200.

By default, the Apitte\Middlewares\ApiMiddleware is registered with priority 500. So you can add as many middlewares as you want.

Middlewares

This package is based on contributte/middlewares. You should register also middleware extension in your config file.

extensions:      
    middlewares: Contributte\Middlewares\DI\MiddlewaresExtension
    api: Apitte\Core\DI\ApiExtension
1
2
3

After that you feel the power of the middlewares.

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

services:
  m1: 
    factory: App\Model\AppMiddleware1
    tags: [middleware: [priority: <int>]]
1
2
3
4

Playground

I've made a repository with full applications for education.

Take a look: https://github.com/apitte/playground