Search code examples
symfony1symfony-1.4

sfConfig::get in a task in symfony


I have tried to use a parameter in my app.yml file inside a task in symfony 1.4, but it doesnt get the value.

sfConfig::get()

Do you have any advice?


Solution

  • By default tasks are ran only with a project - meaning they don't have access to your settings in app.yml. You either need to:

    • explicitly pass an app parameter every time you call the task, this is done like:

      php symfony ns:task --application=frontend
      
    • add it as a default parameter in your configure():

      $this->addOptions(array(
        new sfCommandOption('application', "app", sfCommandOption::PARAMETER_REQUIRED, 'The application name', "frontend")
      ));