DEPRECATED: Use Slim 4 instead, it got PSR15 support out of the box.
A slim psr15 adapter for middleware and request handler.
- php: ^7.0
- psr/container: ^1.0
- psr/http-message: ^1.0.1
- psr/http-server-middleware: ^1.0.1
Through Composer as chubbyphp/chubbyphp-slim-psr15.
composer require chubbyphp/chubbyphp-slim-psr15 "^1.1"
<?php
declare(strict_types=1);
namespace App;
use App\Middleware\Psr15Middleware;
use Chubbyphp\SlimPsr15\MiddlewareAdapter;
use Slim\App;
$app = new App();
$app->add(new MiddlewareAdapter(new Psr15Middleware()));
<?php
declare(strict_types=1);
namespace App;
use App\Middleware\Psr15Middleware;
use Chubbyphp\SlimPsr15\LazyMiddlewareAdapter;
use Psr\Container\ContainerInterface;
use Slim\App;
/** @var ContainerInterface $container */
$container = ...;
$app = new App();
$app->add(new LazyMiddlewareAdapter($container, Psr15Middleware::class));
<?php
declare(strict_types=1);
namespace App;
use App\RequestHandler\Psr15RequestHandler;
use Chubbyphp\SlimPsr15\RequestHandlerAdapter;
use Slim\App;
$app = new App();
$app->get('/', new RequestHandlerAdapter(new Psr15RequestHandler()));
<?php
declare(strict_types=1);
namespace App;
use App\RequestHandler\Psr15RequestHandler;
use Chubbyphp\SlimPsr15\LazyRequestHandlerAdapter;
use Psr\Container\ContainerInterface;
use Slim\App;
/** @var ContainerInterface $container */
$container = ...;
$app = new App();
$app->get('/', new LazyRequestHandlerAdapter($container, Psr15RequestHandler::class));
Dominik Zogg 2019