title: Uncaught PDOException while using Doctrine 2 CLI in ZF2
body: <p>I am getting an uncaught PDO Exception while trying to use the doctrine CLI. I am following <a href="http://marco-pivetta.com/doctrine-orm-zf2-tutorial/#/" rel="nofollow">marco's tutorial</a>.</p>
  
  <p><strong>My configuration is :</strong> 
  ZF 2.5.1 with PHP version 5.5.21</p>
  
  <h2>Zend Server 8.0.2</h2>
  
  <p><strong>Exception Encountered:</strong></p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
    <em>Stack trace:</em>
    0. /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('mysql:host=loca...', 'root', '', Array)
    1. /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(45): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=loca...', 'root', '', Array)
    2. /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'root', '', Array)
    3. /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
    4. /usr/local/zend/apache2/htdocs/website-/vendor/doctrine/dba in /usr/local/zend/apache2/htdocs/website-/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 946</p>
  </blockquote>
  
  <hr>
  
  <p>Can anyone help or give me any suggestion please?</p>
  
  <p>Additional Information:</p>
  
  <ol>
  <li><p>Command used for accessing Doctrine CLI:</p>
  
  <p><code>./vendor/bin/doctrine-module orm:validate-schema</code></p></li>
  <li><p>Contents of /vendor/bin/:</p></li>
  </ol>
  
  <blockquote>
    <p>ABHI  staff    57B Jun  6 00:47 classmap_generator.php -> ../zendframework/zendframework/bin/classmap_generator.php
     ABHI  staff    28B Jun 16 19:46 doctrine -> ../doctrine/orm/bin/doctrine
     ABHI  staff    34B Jun 16 19:46 doctrine-dbal -> ../doctrine/dbal/bin/doctrine-dbal
     ABHI  staff    47B Jun 16 19:46 doctrine-module -> ../doctrine/doctrine-module/bin/doctrine-module
     ABHI  staff    32B Jun 16 19:46 doctrine.php -> ../doctrine/orm/bin/doctrine.php
     root  staff    26B Jun 16 20:26 phpunit -> ../phpunit/phpunit/phpunit
     ABHI  staff    58B Jun  6 00:47 pluginmap_generator.php -> ../zendframework/zendframework/bin/pluginmap_generator.php
     ABHI  staff    60B Jun  6 00:47 templatemap_generator.php -> ../zendframework/zendframework/bin/templatemap_generator.php
     ABHI  staff    30B Jun 16 19:52 zf.php -> ../zendframework/zftool/zf.php</p>
  </blockquote>
  
  <ol start="3">
  <li><p>Snippet from doctrine-module file:</p>
  
  <pre><code>/* @var $cli \Symfony\Component\Console\Application */
  $cli = $application-&gt;getServiceManager()-&gt;get('doctrine.cli');
  exit($cli-&gt;run());
  </code></pre></li>
  <li><p>Throwing error in the following function in the PDOConnection.php file:</p>
  
  <pre><code>public function __construct($dsn, $user = null, $password = null, array $options = null)
  {
      try {
          parent::__construct($dsn, $user, $password, $options);
          $this-&gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array()));
          $this-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      } catch (\PDOException $exception) {
          throw new PDOException($exception);
      }
  }
  </code></pre></li>
  </ol>