Symfony database driver not found exception occured in driver:could not find driver

Source: Internet
Author: User






If you keep reporting this error,



First, you do not have the relevant database driver locally (mysql:-->pdo_myql,postgresql-->pdo_pgsql, etc.);



Need to perform


php-m| Grep-i PDO


See what drive configurations you have;



Driver configuration in: Your local PHP file has a php.ini file, search pdo_myql or Pdo_pgsql, which will be used to remove the preceding comma, the comma in the INI file is the meaning of comments;



Second, when you have already handled these situations, still report this error, then you clean up the cache, of course, if you are using the Phpstom development tool, you can use the ctr+shift+f search MySQL, or you think the configuration is not changed, You may see the corresponding cache in the Appdevdebugprojectcontainer.xml file, so clean it up;



$ php bin/console cache:clear # Clear Cache



Third, if also reported this error, I do not know, self-solve;





$ php bin/console doctrine:database:create


  [Doctrine\DBAL\Exception\DriverException]
  An exception occured in driver: could not find driver



  [Doctrine\DBAL\Driver\PDOException]
  could not find driver



  [PDOException]
  could not find driver


doctrine:database:create [--shard SHARD] [--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-i
nteraction] [-e|--env ENV] [--no-debug] [--] <command>





--------------------Configuration Data information:



First: Locate the Config.yml file:


 
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #path: ‘%database_path%‘


Second: found Parameter.yml file:


 
parameters:
     database_driver: pdo_pgsql database driver, if you use mysql it is pdo_mysql
     database_host: 127.0.0.1
     database_port: null
     database_name: database name
     database_user: database user name
     database_password: database password
     mailer_transport: smtp
     mailer_host: 127.0.0.1
     mailer_user: database user
     mailer_password: database user password
     secret: ThisTokenIsNotSoSecretChangeIt


Third: You can execute: PHP bin/console doctrine:database:create



To create a database;



Of course, you can also write a script to create a database, in short, the connection is successful;






Fourth: Create entities: See http://www.cnblogs.com/Amos-Turing/p/6264044.html this blog



Then you can do it: PHP bin/console doctrine:schema:update--force # Generate database from entity






Symfony database driver not found exception occured in driver:could not find driver


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.