1

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\''
                ],
            ],
        ],
    ],
];
Shadow
  • 33,525
  • 10
  • 51
  • 64
wasor4ik
  • 21
  • 2

2 Answers2

0

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

Tyrsson
  • 1
  • 1
  • 3
0

The error you get:

'Laminas\Db\Adapter\Laminas\Db\Adapter\AdapterInterface' not found

I think there is a namespace issue. Try to use only:

use Laminas\Db;

insted of the one you're currently using.