0

I'm trying to configure doctrine by following this tutorial and when I run that command: ./vendor/bin/doctrine-module orm:validate-schema I get an error:

Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in var/www/CommunicationApp/config/autoload/global.php on line 19

Here is the global.php file:

<?php
/**
 * Global Configuration Override
 *
 * You can use this file for overriding configuration values from modules, etc.
 * You would place values in here that are agnostic to the environment and not
 * sensitive to security.
 *
 * @NOTE: In practice, this file will typically be INCLUDED in your source
 * control, so do not include passwords or other sensitive information in this
 * file.
 */

return array(
  'db' => array(
     'driver'  => 'Pdo',
     'dsn'   => 'mysql:dbname=zf2tutorial;host=localhost',
     'driver_options' => array(
         PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
     ),
 ),
 'service_manager' => array(
     'factories' => array(
         'Zend\Db\Adapter\Adapter'
                 => 'Zend\Db\Adapter\AdapterServiceFactory',
     ),
 ),
);

I already uncomment the extension=php_pdo_mysql.dll in /usr/local/zend/etc/php.ini

John
  • 107
  • 1
  • 3
  • 15

2 Answers2

1

Make sure you have the PHP MySQL extension installed. On Ubuntu that would be:

sudo apt-get install php5-mysql
Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • Now I'm getting this error: [Doctrine\Common\Persistence\Mapping\MappingException] File mapping drivers must have a valid directory path, however the given pa th [/var/www/CommunicationApp/module/CsnFileManager/config/../src/CsnFileMa nager/Entity] seems to be incorrect! – John Dec 12 '13 at 20:14
0

I was having the same problem with this PDO line, then first of all, I installed the php5-mysql package that Tim Fountain posted. The second step was remove the escape from the lines.

'driver_options' => array(
     PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
 ),

After both things, it worked!