laravel-doctrine
laravel-doctrine copied to clipboard
Unsupported driver Exception
Hello again,
In issue #103 I've changed DB_CONNECTION
to mysql
and driver
for this connection to pdo_mysql
. Howere, now there is some issue when I register new user using default AuthController and Doctrine driver provided by this lib.
When I send POST request to localhost/auth/register
to register user I got:
InvalidArgumentException in ConnectionFactory.php line 189:
Unsupported driver [pdo_mysql]
I tried to debug, this. In ConnectionFactory class there's method
public function createConnector(array $config)
{
if (!isset($config['driver'])) {
throw new InvalidArgumentException('A driver must be specified.');
}
if ($this->container->bound($key = "db.connector.{$config['driver']}")) {
return $this->container->make($key);
}
switch ($config['driver']) {
case 'mysql':
return new MySqlConnector;
case 'pgsql':
return new PostgresConnector;
case 'sqlite':
return new SQLiteConnector;
case 'sqlsrv':
return new SqlServerConnector;
}
throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]");
}
And I found that my $config['driver']
is set to pdo_mysql
as expected, but as we can see there's no pdo_mysql
in switch.
How to setup this driver correctly?
Note, that if I switch driver to mysql
in my configuration like this:
connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
],
I've got another exception:
DBALException in DBALException.php line 95:
The given 'driver' mysql is unknown, Doctrine currently supports only the following drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo_sqlsrv, mysqli, drizzle_pdo_mysql, sqlanywhere, sqlsrv
@JacekJagiello I guess this ConnectionFactory is using connection from Laravel and not for Doctrine.
I'm afraid we have no integration with register. =/
I'm running into this road block with using this package with Laravel 5, also.
No one got a fix for this?
Laravel uses mysql to reference the driver and Doctrine requires the value to be pdo_mysql. Somewhere along the line it should map mysql from your laravel config into pdo_mysql before it attempts to create the Doctrine (DBAL) connection.
Still getting this error when I pull dev-master.
You can fix this without changing the code.
In config/database.php use driver mysql
In config/doctrine.php use driver pdo_mysql
config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
config/doctrine.php
# Override your laravel values here if desired.
'mysql' => [
'driver' => 'pdo_mysql',
// 'host' => env('DB_HOST', 'localhost'),
// 'dbname' => env('DB_DATABASE', 'forge'),
// 'user' => env('DB_USERNAME', 'forge'),
// 'password' => env('DB_PASSWORD', ''),
// 'prefix' => ''
],