5

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!

7
  • run php app/check.php Commented Mar 21, 2016 at 22:34
  • php app/check.php shows 3 errors: app/cache, app/logs must be writable, timezone should be set. But it's all about cli. Web server permissions and timezone are correct. web/config.php shows "Your configuration looks good to run Symfony" Commented Mar 21, 2016 at 22:48
  • double check phpinfo() (if you are running symfony in dev environment - there is link to phpinfo in developer toolbar) - if you have both pdo and pdo_sqlite extensions enabled Commented Mar 21, 2016 at 23:01
  • 1
    also, check if in config.yml you have driver set as "%database_driver%" (so it takes the one from parameters.yml), because in new symfony installations there is pdo_mysql by default Commented Mar 21, 2016 at 23:04
  • doctrine dbal driver is %database_driver%. php.ini pdo drives: mysql only in enable column Commented Mar 21, 2016 at 23:07

3 Answers 3

13

Just install:

sudo apt install php-sqlite3
Sign up to request clarification or add additional context in comments.

Comments

9

For me in ubuntu that work

sudo apt-get install php5.6-sqlite

1 Comment

Worked for me with PHP7 and sudo apt install php7.0-sqlite3. A more general/abstract solution would be something like that: sudo apt-get install phpX.Y-sqlite
2

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 ###

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.