【php开源代码栏目提醒】:本文主要为网学会员提供bake.php,希望对需要bake.php网友有所帮助,学习一下!
#!/usr/bin/php -q
<?php
/* SVN FILE: $Id: bake.php 4409 2007-02-02 13:20:59Z phpnut $ */
/**
* Command-line code generation utility to automate programmer chores.
*
* Bake is CakePHP's code generation script, which can help you kickstart
* application development by writing fully functional skeleton controllers,
* models, and views. Going further, Bake can also write Unit Tests for you.
*
* PHP versions 4 and 5
*
* Cake
PHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.scripts.bake
* @since CakePHP(tm) v 0.10.0.1232
* @version $Revision: 4409 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
define ('DS', DIRECTORY_SEPARATOR);
if (function_exists('ini_set')) {
ini_set('display_errors', '1');
ini_set('error_reporting', '7');
ini_set('max_execution_time',60*5);
}
$app = null;
$root = dirname(dirname(dirname(__FILE__)));
$core = null;
$here = $argv[0];
$help = null;
$project = null;
for ($i = 1; $i < count($argv); $i += 2) {
switch ($argv[$i]) {
case '-a':
case '-app':
$app = $argv[$i + 1];
break;
case '-c':
case '-core':
$core = $argv[$i + 1];
break;
case '-r':
case '-root':
$root = $argv[$i + 1];
break;
case '-h':
case '-help':
$help = true;
break;
case '-p':
case '-project':
$project = true;
$projectPath = $argv[$i + 1];
$app = $argv[$i + 1];
break;
}
}
if(!$app && isset($argv[1])) {
$app = $argv[1];
} elseif(!$app) {
$app = 'app';
}
if(!is_dir($app)) {
$project = true;
$projectPath = $app;
}
if($project) {
$app = $projectPath;
}
$shortPath = str_replace($root, '', $app);
$shortPath = str_replace('..'.DS, '', $shortPath);
$shortPath = str_replace(DS.DS, DS, $shortPath);
$pathArray = explode(DS, $shortPath);
if(end($pathArray) != '') {
$appDir = array_pop($pathArray);
} else {
array_pop($pathArray);
$appDir = array_pop($pathArray);
}
$rootDir = implode(DS, $pathArray);
$rootDir = str_replace(DS.DS, DS, $rootDir);
if(!$rootDir) {
$rootDir = $root;
$projectPath = $root.DS.$appDir;
}
define ('ROOT', $rootDir);
define ('APP_DIR', $appDir);
define ('DEBUG', 1);
if(!empty($core)){
define('CAKE_CORE_INCLUDE_PATH', dirname($core));
}else{
define('CAKE_CORE_INCLUDE_PATH', $root);
}
if(function_exists('ini_set')) {
ini_set('include_path',ini_get('include_path').
PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.DS.
PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
define('APP_PATH', null);
define('CORE_PATH', null);
} else {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
require_once (CORE_PATH.'cake'.DS.'basics.php');
require_once (CORE_PATH.'cake'.DS.'config'.DS.'paths.php');
require_once (CORE_PATH.'cake'.DS.'dispatcher.php');
require_once (CORE_PATH.'cake'.DS.'scripts'.DS.'templates'.DS.'skel'.DS.'config'.DS.'core.php');
/*uses ('inflector', 'model'.DS.'model');
require_once (CORE_PATH.'cake'.DS.'app_model.php');
require_once (CORE_PATH.'cake'.DS.'app_controller.php');*/
/*uses ('inflector', 'model'.DS.'model');*/
/*uses ('neat_array', 'model'.DS.'connection_manager', 'controller'.DS.'controller', 'session',
'configure', 'security', DS.'controller'.DS.'scaffold');*/
uses('session', 'configure', 'inflector', 'model'.DS.'connection_manager');
$pattyCake = new Bake();
if($help === true)
{
$pattyCake->help();
exit();
}
if($project === true)
{
$pattyCake->project($projectPath);
exit();
}
$pattyCake->main();
/**
* Bake is a command-line code generation utility for automating programmer chores.
*
* @package cake
* @subpackage cake.cake.scripts
*/
class Bake {
/**
* Standard input stream.
*
* @var filehandle
*/
var $stdin;
/**
* Standard output stream.
*
* @var filehandle
*/
var $stdout;
/**
* Standard e