Slim uses a dependency container to prepare, manage, and inject application dependencies. Slim supports containers that implement the Container-Interop interface. You can use Slim’s built-in container (based on Pimple) or third-party containers like Acclimate or PHP-DI.
You don’t have to provide a dependency container. If you do, however, you must inject the container instance into the Slim application’s constructor.
You can fetch services from your container explicitly or implicitly. You can fetch an explicit reference to the container instance from inside a Slim application route like this:
You can implicitly fetch services from the container like this:
Slim uses __get()
and __isset()
magic methods that defer to the application’s
container for all properties that do not already exist on the application instance.
Your container MUST implement these required services. If you use Slim’s built-in container, these are provided for you. If you choose a third-party container, you must define these required services on your own.
httpVersion
responseChunkSize
outputBuffering
determineRouteBeforeAppMiddleware
.displayErrorDetails
.addContentLengthHeader
.routerCacheFile
.\Slim\Interfaces\Http\EnvironmentInterface
.\Psr\Http\Message\ServerRequestInterface
.\Psr\Http\Message\ResponseInterface
.\Slim\Interfaces\RouterInterface
.\Slim\Interfaces\InvocationStrategyInterface
.\Psr\Http\Message\ResponseInterface
and accept three arguments:\Psr\Http\Message\ServerRequestInterface
\Psr\Http\Message\ResponseInterface
\Error
\Psr\Http\Message\ResponseInterface
and accept three arguments:\Psr\Http\Message\ServerRequestInterface
\Psr\Http\Message\ResponseInterface
\Exception
\Psr\Http\Message\ResponseInterface
and accept two arguments:\Psr\Http\Message\ServerRequestInterface
\Psr\Http\Message\ResponseInterface
\Psr\Http\Message\ResponseInterface
and accept three arguments:\Psr\Http\Message\ServerRequestInterface
\Psr\Http\Message\ResponseInterface
\Slim\Interfaces\CallableResolverInterface
.