Slim Di-bridge with noodlehaus, having problems accessing the variables


#1

Hi,

Im using Slim 3 with DI\Bridge\Slim\App and DI\ContainerBuilder

How can i access the variables & values in the Di-bridge, i have a noodlehaus instance with a configsettings.php file

$app = new App();  // creating the DI\Bridge\Slim\App
$container = $app->getContainer();

$capsule = new Capsule();
//need to get the db settings -- line below problem
$capsule->addConnection($container['config']->get('db'));

file : configsettings.php

return [
    'db' => [
        'driver' => 'mysql',
        'host' => ('localhost'),
        'database' => (''),
        'username' => ('root'),
        'password' => (''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
    ],
    'settings' => [
        'displayErrorDetails' => true,
        'addContentLengthHeader' => false,
    ],
     'image' => [
            'cache' => [
                'path' => '../storage/cache/image/'
            ]
        ]
];

creating the di-bridge

namespace Ti;

use DI\Bridge\Slim\App as DIBridge;
use DI\ContainerBuilder;

class App extends DIBridge
{

    protected function configureContainer(ContainerBuilder $builder)
        {
        $builder->addDefinitions([
            'settings.displayErrorDetails' => true,
            // i could add slim settings here, not sure what to do with Db and image etc 
        ]);
        $builder->addDefinitions(__DIR__ . '/../config/container.php');
        }

}

file : config/container.php Created a new noodlehaus instance and ref the file

return [
    \Noodlehaus\Config::class => function (ContainerInterface $container) {
        new \Noodlehaus\Config([__DIR__ . '/../config/configsettings.php',
        ]);
    },
    RouterInterface::class => function (ContainerInterface $container) {
        return $container->get('router');
    },
    // PS... Disable debug = true and Twig_Extension_Debug - use only for debuging 
    Twig::class => function (ContainerInterface $c) {
        $twig = new Twig(__DIR__ . '/../twig/views', // need to retrieve setting  from noodlehaus