PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Symfony task aodefaulta context

Note: This article was originally published at Planet PHP on 17 April 2820.
Planet PHP

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):Ahttp://www.symfony-project.org/cookbook/1_2/en/tasks