slimphp / Slim-Skeleton

Slim Framework 4 Skeleton Application
http://www.slimframework.com
MIT License
1.58k stars 477 forks source link

Issue with creating the container. #78

Closed milpas999 closed 5 years ago

milpas999 commented 6 years ago

I am trying to create a service for the database connection. I have used the same steps as given in the slim 3 and pimple DI documentation. But Container is not getting created.

$container['dbMeedo'] = function($c) {
    $arrDriverDetails = $settings = $c->get('settings')['dbMeedo'];
    $MedooDb = new Medoo($arrDriverDetails);
    return $MedooDb;
};
geggleto commented 6 years ago

that is not how you construct a container; that is how you define a service in the container.

nhymxu commented 6 years ago

try

$container['dbMeedo'] = function($c) {
    $arrDriverDetails = $c['settings']['dbMeedo'];
    $MedooDb = new Medoo($arrDriverDetails);
    return $MedooDb;
};
akrabat commented 6 years ago

Are you doing $container = $app->getContainer() before using $container?

jimmy18dev commented 6 years ago
$container = $app->getContainer();

$container['renderer'] = function ($c) {
    $settings = $c->get('settings')['renderer'];
    return new Slim\Views\PhpRenderer($settings['template_path']);
};
akrabat commented 6 years ago

@milpas999 Have you resolved your issue?

l0gicgate commented 5 years ago

This issue is stale. Closing.