Before version 1.0 I was writing my batch scripts by hand, usually cutting and pasting from other batch scripts. At some point the
init-batch
command became available. This is how it works:
symfony init-batch default [yourBatchName] [yourApplicationName]
This creates a new file in your project/batch directory with the following content:
<?php /** * yourBatchName batch script * * Here goes a brief description of the purpose of the batch script * * @package yourProject * @subpackage batch * @version $Id$ */ define('SF_ROOT_DIR', realpath(dirname(__file__).'/..')); define('SF_APP', 'yourApplicationName'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', 1); require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); // initialize database manager //$databaseManager = new sfDatabaseManager(); //$databaseManager->initialize(); // batch process here
Nice! Credit goes to those who posted in the forum for details about this great command line tool.




fyi – init-batch is gone in symfony 1.1
look up how to create a task in symfony.
By mo on Oct 26, 2008