Home

Awesome

Build Status Coverage Status

Slim framework universal module

This package integrates the Slim framework (v3) in any container-interop/service-provider compatible framework/container.

Installation

composer require thecodingmachine/slim-universal-module

Once installed, you need to register the TheCodingMachine\SlimServiceProvider into your container.

If your container supports Puli integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register service providers.

Introduction

This service provider is meant to create a base Slim/App instance. You can later play with this instance to add routes, etc...

Expected values / services

This service provider expects the following configuration / services to be available:

NameCompulsoryDescription
settingsnoThe Slim settings (see Slim documentation about settings for more details)

Provided services

Note: Sadly, Slim uses containers as service locators instead of dependency injection containers. This means that the name of the instances is dictated by Slim. The names could collide with some of your services! Be wary of this!

This service provider provides the following services:

Service nameDescription
App::classThe Slim app
settingsThe Slim default settings
environmentInstance of \Slim\Interfaces\Http\EnvironmentInterface.
requestInstance of \Psr\Http\Message\ServerRequestInterface.
responseInstance of \Psr\Http\Message\ResponseInterface.
routerInstance of \Slim\Interfaces\RouterInterface.
foundHandlerInstance of \Slim\Interfaces\InvocationStrategyInterface.
phpErrorHandlerCallable invoked if a PHP 7 Error is thrown. See Slim doc
errorHandlerCallable invoked if an Exception is thrown. See Slim doc
notFoundHandlerCallable invoked if the current HTTP request URI does not match an application route. See Slim doc
notAllowedHandlerCallable invoked if an application route matches the current HTTP request path but not its method. See Slim doc
callableResolverInstance of \Slim\Interfaces\CallableResolverInterface.

Extended services

This service provider registers the Slim\App in the MiddlewareListServiceProvider::MIDDLEWARES_QUEUE.

Service nameDescription
MiddlewareListServiceProvider::MIDDLEWARES_QUEUEAdds the Slim app to this queue (to be used by external routers)