Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a ParameterNotFoundException with Symfony2 in PHP

Tags:

php

symfony

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.

like image 223
Mirage Avatar asked Jul 09 '12 04:07

Mirage


2 Answers

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
like image 200
MDrollette Avatar answered Oct 20 '22 19:10

MDrollette


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 }
like image 42
Anto Avatar answered Oct 20 '22 21:10

Anto