'Fatal error: Trait 'Laminas\Db\Adapter\Laminas\Db\Adapter\AdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php
I keep getting this error when I'm trying to open Album application from Laminas MVC tutorial. I use multicontainer configuration in Docker which consists of linked containers. These are laminas-mvc-tutorial container and mysql database container. PDO mysql is enabled but I think it is something with my Adapter configuration issues. Here is global.php config array:
use Laminas\Db\Adapter;
return [
'service_manager' => [
'abstract_factories' => [
Adapter\AdapterAbstractServiceFactory::class
],
'factories' => [
Adapter\AdapterInterface::class => Adapter\AdapterServiceFactory::class,
],
'aliases' => [
Adapter\Adapter::class => Adapter\AdapterInterface::class
]
],
'db' => [
'driver' => 'Pdo',
'adapters' => [
mysqlAdapter::class => [
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=Laminas;host=localhost;charset=utf8',
'username' => 'root',
'port' => '3306',
'password' => 'pass1234',
'driver_options' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
],
],
],
],
];
Solution 1:[1]
As far as I am aware. All of this:
'abstract_factories' => [
Adapter\AdapterAbstractServiceFactory::class
],
'factories' => [
Adapter\AdapterInterface::class => Adapter\AdapterServiceFactory::class,
],
'aliases' => [
Adapter\Adapter::class => Adapter\AdapterInterface::class
]
Is not needed. If you are following the docs why are you not in development mode instead of production? Since in development mode this should be read from the local.php file instead of global.php?
'db' => [
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=your_dbname;host=localhost;charset=utf8',
'username' => 'your_username',
'password' => 'your_password',
],
Which is literally the only thing needed to connect to MySQL for laminas/laminas-db
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tyrsson |