简体   繁体   中英

Getting a ParameterNotFoundException with Symfony2 in PHP

I am new to Symfony2 and I have been following the symblog tutorial

But I get this error when I load the homepage

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

Where should I check for that whether in config.yml if config.yml in which statement it should be edited.

That parameter will be set in your app/config/parameters.ini (or .yml on newer versions). Make sure that file exists and looks something like this:

[parameters]
    database_driver   = pdo_mysql
    database_host     = localhost
    database_port     =
    database_name     = symfony
    database_user     = root
    database_password =

    mailer_transport  = smtp
    mailer_host       = localhost
    mailer_user       =
    mailer_password   =

    locale            = en

    secret            = ThisTokenIsNotSoSecretChangeIt

I had the same problem and it turned out that I added a second imports section in my config.yml. So I removed it and just added my resource in the top imports section at the top of the file and now it works! I was adding the sonata admin service. Hope this helps.

imports:

      - { resource: parameters.yml }

      - { resource: security.yml }

      - { resource: @MyBundle/Resources/config/admin.yml }

Instead of the incorrect

imports:

      - { resource: parameters.yml }

      - { resource: security.yml }

imports:

      - { resource: @MMyBundle/Resources/config/admin.yml }

I also studied this article. And I also got this error. As found. I did not correctly copied the example in the file app / config / config.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