A good friend of mine just told me that it’s really hard to find useful documentation about batch processing with Symfony Framework. You can find here everything you need! Please follow the instructions below:
symfony init-batch default [MyBatch] [MyApplication]
init-batch command will create a batch file into batch folder which is located in your Symfony project folder. When you open the file with a text editor, you’ll see something like that:
<?php
/**
* test batch script
*
* Here goes a brief description of the purpose of the batch script
*
* @package project
* @subpackage batch
* @version $Id$
*/
define(’SF_ROOT_DIR’, realpath(dirname(__file__).’/..’));
define(’SF_APP’, ‘app’);
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
Now, you can put your own codes after the line which is containing ‘batch process here’. Eventually, you can run your script on CLI.