Home > Uncategorized > Symfony task “default” context

Symfony task “default” context

When creating Symfony 1.4 CLI tasks, I stumbled upon an error message:

The "default" context does not exist.

After searching some old forums, I found a solution. Before you access any Doctrine class, you mus first bootstrap your context correctly. Here is an example:

$config = ProjectConfiguration::getApplicationConfiguration(
  'frontend',
  'dev',
   false
);
sfContext::createInstance($config);

              
The application name and the environment can come from CLI options. More on Doctrine tasks (I could only find 1.2 equivalent): http://www.symfony-project.org/cookbook/1_2/en/tasks
Tags: ,
  1. No comments yet.
  1. No trackbacks yet.