Mirage
Mirage

Reputation: 31568

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.

Upvotes: 7

Views: 7518

Answers (3)

Anto
Anto

Reputation: 41

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 }

Upvotes: 3

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

Upvotes: 0

MDrollette
MDrollette

Reputation: 6927

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

Upvotes: 4

Related Questions