php Symfony2:您请求了一个不存在的参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33023299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Symfony2: You have requested a non-existent parameter
提问by Jér?me Verstrynge
I have checked similar questions on SO, but they did not solve my issue.
我在 SO 上检查了类似的问题,但他们没有解决我的问题。
I am deploying a Symfony2 application on Openshift. It works well on my Windows 10 laptop, but I am getting the following error messageon Openshift:
我正在 Openshift 上部署一个 Symfony2 应用程序。它在我的 Windows 10 笔记本电脑上运行良好,但我在 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:
我的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
is:
我的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
is:
我的config_prod.yml
是:
imports:
- { resource: config.yml }
...
What am I doing wrong?
我究竟做错了什么?
Update
更新
I have changed my config.yml
to:
我已更改config.yml
为:
path: "%kernel.root_dir%/../data/demo.db"
and the issue is gone, but I don't know why!
问题消失了,但我不知道为什么!
回答by felipsmartins
This is a common mistake.
这是一个常见的错误。
Just like I have commented above:
When running composerinstall, 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.
就像我上面评论的那样:
运行composerinstall 时,symfony 将parameters.yml
根据parameters.yml.dist
(如果有)重新生成一个新文件。
因此,最好始终检查parameters.yml
symfony 生成的(在安装后事件中,作曲家)是否正常。
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.
每当您更新
parameters.yml
文件时(配置也应该在生产服务器中),您也必须更新文件parameters.yml.dist
。
So the deployment process will be much less painful.
所以部署过程会少很多痛苦。