ParameterNotFoundException:您已请求不存在的参数“database_accounts_driver”

时间:2013-06-27 00:11:24

标签: symfony symfony-2.1

当我使用compser.phar更新symfony2项目时:

php composer.phar update

我在更新后运行项目时遇到此错误:

ParameterNotFoundException: You have requested a non-existent parameter "database_accounts_driver".

这是我的config.yml:

# Doctrine Configuration
doctrine:
dbal:
    default_connection:       default
    connections:
        default:
            driver:   "%database_driver%"
            host:     "%database_host%"
            port:     "%database_port%"
            dbname:   "%database_name%"
            user:     "%database_user%"
            password: "%database_password%"
            charset:  UTF8
        accounts:
            driver:   "%database_accounts_driver%"
            host:     "%database_accounts_host%"
            port:     "%database_accounts_port%"
            dbname:   "%database_accounts_name%"
            user:     "%database_accounts_user%"
            password: "%database_accounts_password%"
            charset:  UTF8

也是我的parameter.yml:

parameters:
database_driver:   pdo_mysql
database_host:     127.0.0.1
database_port:     ~
database_name:     symfony
database_user:     root
database_password: ~

mailer_transport:  smtp
mailer_host:       127.0.0.1
mailer_user:       ~
mailer_password:   ~

locale:            en
secret:            ThisTokenIsNotSoSecretChangeIt

最后是我的appkernel:

$bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),
        new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new JMS\AopBundle\JMSAopBundle(),
        new JMS\DiExtraBundle\JMSDiExtraBundle($this),
        new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),

任何想法?

1 个答案:

答案 0 :(得分:1)

我可以看到,yout parameters.yml中没有定义database_accounts_driver 你有database_driver,database_host,database_name ...买NOT database_ACCOUNTS_driver(也不是database_accounts_host等等)

如果要使用不同的参数进行默认和帐户配置,则必须在parameters.yml中定义:

parameters:
    database_driver:   pdo_mysql
    database_host:     127.0.0.1
    database_port:     ~
    database_name:     symfony
    database_user:     root
    database_password: ~

    database_accounts_driver:   pdo_mysql
    database_accounts_host:     127.0.0.1
    database_accounts_port:     ~
    database_accounts_name:     whatever
    database_accounts_user:     whatever
    database_accounts_password: blablabla

    mailer_transport:  smtp
    mailer_host:       127.0.0.1
    mailer_user:       ~
    mailer_password:   ~

    locale:            en
    secret:            ThisTokenIsNotSoSecretChangeIt