2017 © Pedro Peláez
 

library symfony-middleware

Symfony Middleware based on PSR-15

image

enalquiler/symfony-middleware

Symfony Middleware based on PSR-15

  • Tuesday, January 23, 2018
  • by enalquiler
  • Repository
  • 3 Watchers
  • 0 Stars
  • 86 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 51 % Grown

The README.md

Symfony PSR-15 Middleware

A dead-simple PSR-15 middleware to run Symfony as a middleware., (*1)

Installation

composer require enalquiler/symfony-middleware

Usage

With Zend Stratigility

Zend Stratigility, (*2)

<?php

use Zend\Diactoros\Response;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
use Zend\Stratigility\NoopFinalHandler;
use Enalquiler\Middleware\SymfonyMiddleware;

require __DIR__ . '/../vendor/autoload.php';

$app = new MiddlewarePipe();
$app->setResponsePrototype(new Response());

$kernel = new AppKernel('dev', true);

$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);

$app
    ->pipe(new SymfonyMiddleware($kernel))
    ->pipe('/foo', function ($req, $res, $next) {
        $res->getBody()->write('FOO!');
        return $res;
    })
;

$server->listen(new NoopFinalHandler());

With Middleman

<?php

use Psr\Http\Message\RequestInterface as Request;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
use mindplay\middleman\Dispatcher;
use Enalquiler\Middleware\SymfonyMiddleware;

$kernel = new AppKernel('dev', true);

$dispatcher = new Dispatcher([
    new SymfonyMiddleware($kernel),
    function (Request $request) {
        return (new Response())->withBody(...); // abort middleware stack and return the response
    },
    // ...
]);

$response = $dispatcher->dispatch(new ServerRequest($_SERVER, $_FILES));

Running the tests

php vendor/bin/phpunit

Authors

  • David Martínez - Initial work
  • Christian Soronellas
  • Enalquiler Engineering

See also the list of contributors who participated in this project., (*3)

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*4)

Acknowledgments

  • This middleware was inspired by the work of https://github.com/thecodingmachine/symfony-middleware

The Versions

23/01 2018

dev-master

9999999-dev

Symfony Middleware based on PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enalquiler Team

middleware psr psr7 symfony psr15

23/01 2018

3.0.0

3.0.0.0

Symfony Middleware based on PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enalquiler Team

middleware psr psr7 symfony psr15

07/09 2017

2.0.0

2.0.0.0

Symfony Middleware based on PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enalquiler Team

middleware psr psr7 symfony psr15

06/09 2017

1.0.0

1.0.0.0

Symfony Middleware based on PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enalquiler Team

middleware psr psr7 symfony psr15