简体   繁体   中英

Symfony: The service … has a dependency on a non-existent parameter kernel.secret

I'm trying to setup a new Symfony project. When I do a "php console.php config:dump-reference", I get an error saying 'The service "uri_signer" has a dependency on a non-existent parameter "kernel.secret". Did you mean this: "kernel.charset"?'

I have verified the secret is set in config/parameters.yml:

parameters:
    secret: s3kr3t

I have verified the parameters is imported in the config/config.yml:

imports:
    - { resource: parameters.yml }

If I change parameters.yml to the following it works (but this isn't correct, according to all documentation on the web):

parameters:
    kernel.secret: s3kr3t

That means that kernel.secret hasn't been set, this value is used for generation of CSRF-tokens but could be used for other things as well.

Make sure kernel.secrect is known in parameters.yml and import it in config.yml as follows:

imports:
    - { resource: parameters.yml }

parameters.yml:

parameters:
    kernel.secret: ThisIsVerySecret!

Or how it's done in de standard edition:

config.yml:

framework:
    secret:          "%secret%"

parameters.yml

parameters:
     secret: ThisIsVerySecret!

如果类似的问题忘记在parameters_dev.yml添加它,那么请检查您在哪个环境中工作以及是否为该环境设置了它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM