Skip to content
Integrating Slim Framework + Unbox dependency injection container.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Bringing mindplay/unbox into Slim Framework.


Via Composer:

composer require geekish/slimbox


Service Provider

The most important class in this package is Geekish\Slimbox\DefaultServicesProvider. It ensures the same services required by Slim are available through Unbox. Besides the change in container, it differs from Slim\DefaultServicesProvider by registering services under their FQCN first, then registers aliases by their interfaces, and finally the short aliases used by slim (e.g. "router", "foundHandler"). Registering services by their class name enables Unbox to automatically inject them as dependencies as needed by other classes.

The service provider is not automatically registered for you, so you need to do this yourself:

use Geekish\Slimbox\DefaultServicesProvider;
use mindplay\unbox\ContainerFactory;

$factory = new ContainerFactory;
$factory->add(new DefaultServicesProvider);

$container = $factory->createContainer();


Also included is Geekish\Slimbox\Settings, which extends from Slim\Collection. This class replaces the simple array that Slim registers under "settings" (see: Slim Default Settings).

Settings may be provided via the constructor of the DefaultServicesProvider:

$factory->add(new DefaultServicesProvider([
    "outputBuffering" => "prepend",

Or via the configure() method on ContainerFactory:

    function (Settings $settings) {
        $settings['displayErrorDetails'] = true;
        return $settings;

Container and Container Factory (Optional)

This package contains an extended (final) Container and ContainerFactory from Unbox. Usage is almost exactly the same as using Unbox directly, except the extended Container partially implements ArrayAccess. This allows you to use the Container like an array to access services; however, due to the fact that Unbox uses a factory class to create the container, you cannot use array notation to set/configure services on the Container.

To use the extended ContainerFactory:

use Geekish\Slimbox\ContainerFactory;
use Geekish\Slimbox\DefaultServicesProvider;
use Slim\App;

$factory = new ContainerFactory;
$factory->add(new DefaultServicesProvider([
    "outputBuffering" => "prepend",

$container = $factory->createContainer();

Usage of the packaged Container and ContainerFactory is entirely optional; they are included purely for convenience and consistency with Slim's packaged Container. Simply replace Geekish\Slimbox\ContainerFactory in the snippet above with mindplay\unbox\ContainerFactory.

Change log

Please see CHANGELOG for more information what has changed recently.


$ composer test


Please see CONTRIBUTING and CONDUCT for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.