I am getting an uncaught PDO Exception while trying to use the doctrine CLI. I am following marco's tutorial.
My configuration is : ZF 2.5.1 with PHP version 5.5.21
Zend Server 8.0.2
Exception Encountered:
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 Stack trace: 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
Can anyone help or give me any suggestion please?
Additional Information:
Command used for accessing Doctrine CLI:
./vendor/bin/doctrine-module orm:validate-schema
Contents of /vendor/bin/:
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
Snippet from doctrine-module file:
/* @var $cli \Symfony\Component\Console\Application */ $cli = $application->getServiceManager()->get('doctrine.cli'); exit($cli->run());
Throwing error in the following function in the PDOConnection.php file:
public function __construct($dsn, $user = null, $password = null, array $options = null) { try { parent::__construct($dsn, $user, $password, $options); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array())); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (\PDOException $exception) { throw new PDOException($exception); } }