Symfony3 demo project don't work: PDO Exception Could not find driver (sqlite case)

13,409

Solution 1

Just install:

sudo apt install php-sqlite3

Solution 2

For me in ubuntu that work

sudo apt-get install php5.6-sqlite

Solution 3

On my system, this worked. Might not be for everyone though:

  1. I had used Symfony earlier this year, with PostGRESQL
  2. Today I did what I thought was a clean symfony project install, using composer and the directions at symfony.com
  3. I got the error you described \
  4. I looked at everything. Finally saw, for some reason, my .env was set to use postGreSQL. Commented that line back out of the /.env file and set it for SQLite:
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
# DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

Share:
13,409
Andrew
Author by

Andrew

Updated on June 06, 2022

Comments

  • Andrew
    Andrew almost 2 years

    Recently i've created Symfony3 project by command:

    symfony new myproject
    

    The project uses mysql and it works fine.

    After that i've created demo project to study symfony best practices:

    symfony demo
    

    Project was created successfully. Config.php shows, that everything is ok. app_dev.php was successfully opened in my web browser. But when i try to open "http://localhost/app_dev.php/ru/blog/" (there is a public part of the app) 500 internal server error will appear. /app_dev.php/ru/blog/ shows:

    Error message:

    An exception occured in driver: could not find driver

    500 Internal Server Error - DriverException

    2 linked Exceptions:

    PDOException »

    PDOException »

    Critical part in call stack:

    CRITICAL - Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occured in driver: could not find driver" at /var/www/symfony_demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php line 85

    I've read all stack exchange issues about PDO Exception, but none helps me...

    I use Ubuntu, Nginx.

    Mysql, sqlite, php5-sqlite, sqlite3, libsqlite3-dev are installed. Nginx and php5-fpm are restarted. php.ini SQLite 3.x driver for PDO Wez Furlong.

    Demo app parameters.yml:

    database_driver: pdo_sqlite
    database_host: 127.0.0.1
    database_port: null
    database_name: null
    database_user: root
    database_password: null
    database_path: '%kernel.root_dir%/data/blog.sqlite'
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: secret_value_for_symfony_demo_application
    

    php.ini file:

    [sqlite]
    ; http://php.net/sqlite.assoc-case
    ;sqlite.assoc_case = 0
    
    [sqlite3]
    ;sqlite3.extension_dir =
    

    I have no idea, what is the reason of the problem and how to resolve it.

    Help please!