How to use sqlite database on symfony2 project?
Here is what I needed to get SQLite to work, just after doing symfony new myapp
:
in app/config.yml
:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_sqlite
path: "%database_path%"
In app/config/parameters.yml
:
parameters:
database_path: "%kernel.root_dir%/db/myapp_%kernel.environment%.db3"
...
Next I could do a composer install
, create a new entity and it just worked.
According to Doctrine the elements used for sqlite DBAL configuration are:
- user (string): Username to use when connecting to the database.
- password (string): Password to use when connecting to the database.
- path (string): The filesystem path to the database file. Mutually exclusive with memory. path takes precedence.
- memory (boolean): True if the SQLite database should be in-memory (non-persistent). Mutually exclusive with path. path takes precedence.
This is also listed in the full reference for Doctrine configuration in Symfony2, although not elaborated on.
So you need to switch up your config params to match whats appropriate for sqlite.