Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

A slim psr15 adapter for middleware and request handler.

License

Notifications You must be signed in to change notification settings

chubbyphp-legacy/chubbyphp-slim-psr15

Repository files navigation

chubbyphp-slim-psr15

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Monthly Downloads Latest Stable Version Latest Unstable Version

Description

DEPRECATED: Use Slim 4 instead, it got PSR15 support out of the box.

A slim psr15 adapter for middleware and request handler.

Requirements

  • php: ^7.0
  • psr/container: ^1.0
  • psr/http-message: ^1.0.1
  • psr/http-server-middleware: ^1.0.1

Installation

Through Composer as chubbyphp/chubbyphp-slim-psr15.

composer require chubbyphp/chubbyphp-slim-psr15 "^1.1"

Usage

Middleware adapter

<?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()));

Lazy Middleware adapter

<?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));

RequestHandler adapter

<?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()));

Lazy RequestHandler adapter

<?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));

Copyright

Dominik Zogg 2019