. * * Small command line script to bundle Doctrine classes in a single file. * * @author Nicolas BĂ©rard-Nault * @author Konsta Vesterinen * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision$ * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 */ if (count($argv) < 2) { echo "Usage: bundle.php [Target file] \n\n". "Note: If the library directory is ommited, the path will be deducted if possible\n"; exit(1); } else if (count($argv) == 3) { $doctrineBaseDir = $argv[2]; } else { $pathInfos = pathinfo($_SERVER['PHP_SELF']); $Cnt = 0; if ($_SERVER['PHP_SELF'][0] == '/') { $doctrineBaseDir = str_replace('tools/cli/' . $pathInfos['basename'], 'lib', $_SERVER['SCRIPT_NAME'], &$Cnt); } else { $doctrineBaseDir = str_replace('tools/cli/'. $pathInfos['basename'], 'lib', getcwd() .'/'. $_SERVER['SCRIPT_NAME'], &$Cnt); } if ($Cnt != 1) { echo "Can't find library directory, please specify it as an argument\n"; exit(1); } } $targetFile = $argv[1]; echo "Target file: $targetFile" . PHP_EOL; echo "Base directory: $doctrineBaseDir" . PHP_EOL; echo PHP_EOL; set_include_path(get_include_path() . PATH_SEPARATOR . $doctrineBaseDir); require_once 'Doctrine.php'; require_once 'Doctrine/Compiler.php'; spl_autoload_register(array('Doctrine', 'autoload')); echo "Bundling classes and interfaces..." . PHP_EOL; Doctrine_Compiler::compile($targetFile); echo PHP_EOL . "Bundle complete." . PHP_EOL; echo "File: $targetFile (size: ". number_format(filesize($targetFile) / 1024, 2, '.', '') ." kb)." . PHP_EOL; exit(0); ?>