Symfony2: you requested a nonexistent parameter

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

I am deploying a Symfony2 application in Openshift. It works well on my Windows 10 laptop, but I get the following error message in 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 :

 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 :

 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 :

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

What am I doing wrong?

Update

I changed my config.yml to:

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

and the problem disappeared, but I don’t know why!

+7
php symfony openshift
source share
1 answer

This is a common mistake.

As I said above:
When the linker starts, symfony will restore a new parameters.yml file based on parameters.yml.dist (if any).
So a good idea always checks if there are parameters.yml generated by symfony (in post post event, composer).

also:

Whenever you update the parameters.yml file (with the configurations that should also be on the prod server), you should update the parameters.yml.dist file too.

Thus, the deployment process will be much less painful.

+27
source share

All Articles