How to use objects created in dependency file in same file itself


#1

How to use objects created in dependency file in same file itself
for example :

// DIC configuration

$container = $app->getContainer();

//slimsession
$container[‘session’] = function ($c) {
return new \SlimSession\Helper();
};

$container[‘customerdb’] = function ($c) {
$settings = $c->get(‘settings’)[‘db’];
$dbprefix = $app->session->get(‘user_companies_customer_id’);
$custdb = $dbprefix.$settings[‘cdatabase’];
return new Dabble\Database($settings[‘chost’],$settings[‘cusername’],$settings[‘cpassword’],$custdb);
};

like as shown in above example


#2

Do you mean using the session object? That would be:

$container['customerdb'] = function($container) {
    $session = $container->get('session');
    // ...
};

#3

Thanks for your reply will try this.