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!
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 fileparameters.yml.dist
too.
So the deployment process will be much less painful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With