July 16, 2007 – 11:57am Symfony init-batch

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.

Posted in  Uncategorized   |     |  delicious  Digg

1 Trackback(s)

  1. Jul 23, 2007: rpsblog.com » A week of symfony #29 (16-&gt;22 July 2007)

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word