Stack

Composing HttpKernelInterface middlewares since 2013!


A common layer

What do we want? Re-use at the web layer!

Superglobals and side-effecting output mechanisms of PHP make this challenging and force every framework to re-invent.

But Symfony's HttpKernelInterface provides a solid interface, which makes creating and sharing framework-agnostic HTTP filters a breeze!


HttpKernel

The HttpKernelInterface models web request and response as PHP objects, giving them value semantics.

HttpKernel

What is Stack?

Stack is a convention for composing HttpKernelInterface middlewares.

Kernel Onion

By wrapping your application in decorators you can add new behaviour from the outside.


Supported frameworks

  • Symfony 2
  • Silex
  • Laravel 4
  • Drupal8
  • eZ Publish 5
  • Yolo

See the full list on symfony.com


Conventions

A stack middleware is just an object that follows these conventions:

  1. 1
    Implement the HttpKernelInterface
  2. 2
    Take the decorated app as the first constructor argument
  3. 3
    Decorate the handle call, delegate to the decorated app

Yes, leveraging the HTTP interface is that easy!