SlimFit Application

SlimFit has a application object that extends Slim Application, it used Singleton to make sure only 1 application running.

Get application instance

$app = \App\SlimFit::getInstance()
// or use helper function
$app = app();

Dependency Container

SlimFit uses Pimple as Dependency Container because it’s very lightweight and flexible. You can read its documentation in Homepage.

Get service, factory by key

$container = app()->getContainer();
$value = $container->get($key);
$value2 = $container[$key2]
// or use helper function
$value3 = app($key3);

Get application config

SlimFit application autoload all PHP files in config folder to retrieve array of config then put in DI Container via a namespace key config.[filename_without_extension].

File : config/console.php

return [
    '' => 'SlimFit console',

Getting that config

$console_name = $container['config.console'][''];
// or short way
$console_name = app('config.console')[''];

Service provider

Service provider MUST implements \Pimple\ServiceProviderInterface We have some common service providers in app\ServiceProvider : Monolog, Console, Capsule and Twig

You SHOULD register service provider in bootstraping of Application at bootstrap/app.php, you can see we had 2 core service providers : Monolog and HttpKernel

$service_providers = [
    App\ServiceProvider\Monolog::class => [], 
    App\ServiceProvider\HttpKernel::class => [], 

    // Your service providers below
    App\ServiceProvider\Example::class => $config_replace_in_container, 

which $config_replace_in_container is an array of key-value config will be replaced in DI Container.