title: ZF2 + Doctrine 2 : Cli Tool has Access Denied
body: <p>I have a ZF2 2.1.3 app with Doctrine 2.</p>
  
  <p>I installed using composer:</p>
  
  <pre><code>    "zendframework/zendframework": "2.*"
      ,"doctrine/doctrine-orm-module":       "dev-master"
  </code></pre>
  
  <p>A create a file <code>config/autoload/database.local.php</code> with the following:</p>
  
  <pre><code>return array(
      'doctrine' =&gt; array(
          'connection' =&gt; array(
              // Default connection name
              'orm_default' =&gt; array(
              'driverClass' =&gt; 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                  'params' =&gt; array(
                      'host'     =&gt; 'localhost',
                      'port'     =&gt; '3306',
                      'dbname'   =&gt; 'zf2-experimental',
                      'user'     =&gt; 'root',
                      'password' =&gt; '',
                  ),
              ),
          ),
      ),
  );
  </code></pre>
  
  <p>I create my entity <code>Bar</code> under <code>Foo</code> module (<code>src/Business/Entity/Bar.php</code>) and configure it on <code>module.config.php</code> like this:</p>
  
  <pre><code>'doctrine' =&gt; array(
      'driver' =&gt; array(
          __NAMESPACE__ . '_driver' =&gt; array(
              'class' =&gt; 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
              'cache' =&gt; 'array',
              'paths' =&gt; array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Business/Entity'),
          ),
          'orm_default' =&gt; array(
              'drivers' =&gt; array(
                  __NAMESPACE__ . '\Business\Entity' =&gt; __NAMESPACE__ . '_driver',
              ),
          ),
      ),
  ),
  </code></pre>
  
  <p>Ok! It's exactly at <a href="http://samminds.com/2012/07/install-doctrine-2-for-zend-framework-2/" rel="nofollow">Sam says here</a>!</p>
  
  <p>Then I create a simple <code>Foo</code> entity and run the doctrine cli tool:</p>
  
  <pre><code>c:\wamp\www\zf2-Experimental&gt;.\vendor\bin\doctrine-module.bat orm:validate-schema
      [Mapping]  OK - The mapping files are correct.
  
        [PDOException]
        SQLSTATE[28000] [1045] Access denied for user 'username'@'localhost' (using password: YES)
  
      orm:validate-schema
  c:\wamp\www\zf2-Experimental&gt;
  </code></pre>
  
  <p>Looks like the cli tool can get my connection parameters in my <code>config/autoload/database.local.php</code>!</p>
  
  <p>On Application index I tested my config:</p>
  
  <pre><code>$config = $this-&gt;getServiceLocator()-&gt;get('config');
  \Zend\Debug\Debug::dump($config['doctrine']['connection']['orm_default']);
  </code></pre>
  
  <p>And this returned:</p>
  
  <pre><code>array (size=4)
    'configuration' =&gt; string 'orm_default' (length=11)
    'eventmanager' =&gt; string 'orm_default' (length=11)
    'params' =&gt; 
      array (size=5)
        'host' =&gt; string 'localhost' (length=9)
        'port' =&gt; string '3306' (length=4)
        'user' =&gt; string 'root' (length=4)
        'password' =&gt; string '' (length=0)
        'dbname' =&gt; string 'zf2-experimental' (length=16)
    'driverClass' =&gt; string 'Doctrine\DBAL\Driver\PDOMySql\Driver' (length=36)
  </code></pre>
  
  <p>Someone can, please, help me?! :)
  Thanks you all!</p>