12

I have checked similar questions on SO, but they did not solve my issue.

I am deploying a Symfony2 application on Openshift. It works well on my Windows 10 laptop, but I am getting the following error message on Openshift:

Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException'
with message 'You have requested a non-existent parameter "database_path".
Did you mean one of these: "database_host", "database_port", "database_name", "database_user"?'
in /var/lib/openshift/55eed4837628e1199f0000bb/app-root/runtime/repo/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:106 Stack trace: #0 
/var/lib/openshift/55eed4837628e1199f0000bb/app-root/runtime/repo/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php(248):
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->get('database_path') #1 [internal function]:
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->Symfony\Component\DependencyInjection\ParameterBag\{closure}(Array) #2
/var/lib/openshift/55eed4837628e1199f0000bb/app-root/runtime/repo/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php in
/var/lib/openshift/55eed4837628e1199f0000bb/app-root/runtime/repo/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php on line 106

My config.yml is:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
...

doctrine:
    dbal:
        driver:   pdo_sqlite
        charset:  UTF8
        path:     "%kernel.root_dir%/../%database_path%"
...

My parameters.yml is:

parameters:
    database_driver: pdo_sqlite
    database_host: localhost
    database_port: null
    database_name: demo.db
    database_user: root
    database_password: null
    database_path: /data/demo.db
    ...

and my config_prod.yml is:

imports:
    - { resource: config.yml }
...

What am I doing wrong?

Update

I have changed my config.yml to:

path:     "%kernel.root_dir%/../data/demo.db"

and the issue is gone, but I don't know why!

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • 1
    Did you get the exception also in the dev environment? Did you run `cache:clear`? – Federkun Oct 08 '15 at 18:33
  • 1
    I did not have this issue when running `app_dev.php`. I have just ssl logged into my openshift application and ran `php app/console cache:clear --env=prod`. I am getting exactly the same error from the command line... – Jérôme Verstrynge Oct 08 '15 at 18:41
  • 1
    Always running composer install, symfony regenerate a new config.yml from config.yml.dist. Disd you have updated your config.yml.dist? From openshift SSH check if config.yml is okay. `$ cat $OPENSHIFT_REPO_DIR/app/config/parameters.yml` – felipsmartins Oct 08 '15 at 19:12
  • Mmmm the `cat` command reveals that the parameter was not in my `parameters.yml`. Indeed, I did not update it in `.dist`. Newbie error. @felipsmartins If you create the solution, I'll approve it. Thanks. – Jérôme Verstrynge Oct 08 '15 at 19:37

1 Answers1

38

This is a common mistake.

Just like I have commented above:
When running composer install, symfony will regenerate a new parameters.yml file based on parameters.yml.dist (if any).
So it's a good idea always check if parameters.yml generated by symfony (on post install event, composer) is okay.

Also:

Whenever you update the parameters.yml file (with configs that should be in the prod server also well), you must update the file parameters.yml.dist too.

So the deployment process will be much less painful.

felipsmartins
  • 13,269
  • 4
  • 48
  • 56