Answer the question
In order to leave comments, you need to log in
Maybe someone knows what the problem is?
The application could not run because of the following error:
Details
Type: TypeError
Message: Argument 1 passed to Illuminate\Database\Capsule\Manager::addConnection() must be of the type array, object given, called in /var/www/gift/bootstrap/app.php on line 40
File: /var/www/gift/vendor/illuminate/database/Capsule/Manager.php
Line: 118
Trace
#0 /var/www/gift/bootstrap/app.php(40): Illuminate\Database\Capsule\Manager->addConnection(Object(Slim\Collection))
#1 /var/www/gift/vendor/pimple/pimple/src/Pimple/Container.php(118): {closure}(Object(Slim\Container))
#2 /var/www/gift/vendor/slim/slim/Slim/Container.php(123): Pimple\Container->offsetGet('db')
#3 /var/www/gift/vendor/slim/slim/Slim/Container.php(172): Slim\Container->get('db')
#4 /var/www/gift/app/Controllers/Controller.php(16): Slim\Container->__get('db')
#5 /var/www/gift/app/Controllers/HomeController.php(11): App\Controllers\Controller->__get('db')
#6 [internal function]: App\Controllers\HomeController->index(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#7 /var/www/gift/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#8 /var/www/gift/vendor/slim/slim/Slim/Route.php(335): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#9 /var/www/gift/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 /var/www/gift/vendor/slim/slim/Slim/Route.php(313): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 /var/www/gift/vendor/slim/slim/Slim/App.php(495): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#12 /var/www/gift/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#13 /var/www/gift/vendor/slim/slim/Slim/App.php(388): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#14 /var/www/gift/vendor/slim/slim/Slim/App.php(296): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#15 /var/www/gift/public/index.php(5): Slim\App->run()
#16 {main}
$app = new \Slim\App([
'settings' => [
'determineRouteBeforeAppMiddleware' => false,
'displayErrorDetails' => true,
],
'db'=> [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'slim',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]
]);
$container = $app->getContainer();
$container['db'] = function ($container) {
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection($container['settings']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
return $capsule;
};
Answer the question
In order to leave comments, you need to log in
$capsule->addConnection($container['settings']);
Argument 1 passed to Illuminate\Database\Capsule\Manager::addConnection() must be of the type array, object given
here is the doc
https://www.slimframework.com/docs/cookbook/databa...
['db'] no
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question