Symfony2 Database Config

database, php, sql, symfony

Solution

If it's standard Symfony2 project you have to configure your database connection information in `app/config/parameters.yml`, like:

# app/config/parameters.yml
parameters:
    database_driver:    pdo_mysql
    database_host:      localhost
    database_name:      test_project
    database_user:      root
    database_password:  password

# ...

More in doc.

After that you have to create database:

$ php app/console doctrine:database:create

Next, create table schema:

$ php app/console doctrine:schema:update --force

Also, you could load (if your co-worker provided it ; ) some data fixtures, so try:

$ php app/console doctrine:fixtures:load

If your coworker doesn't use doctrine fixtures you should consider dumping data from your prod database.

Problem

I've just inherited a Symfony2 project from a former co-worker. I'm trying to get it running locally, but am getting a SQLSTATE[HY000] [2002] Connection refused error. I guess I'm missing the database connection that I've read should be in the app/config/parameters.yml file. Is there anyway of finding this information if all I have is the project and the live site?

Original source