Symfony2:您已请求不存在的参数

时间:2015-10-08 18:25:24

标签: php symfony openshift

我在SO上检查了类似的问题,但他们没有解决我的问题。

我正在Openshift上部署Symfony2应用程序。它在我的Windows 10笔记本电脑上运行良好,但我在Openshift上得到以下error message

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

我的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%"
...

我的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
    ...

我的config_prod.yml是:

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

我做错了什么?

更新

我已将config.yml更改为:

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

问题已经消失,但我不知道为什么!

0 个答案:

没有答案