本文整理汇总了PHP中Generator::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::init方法的具体用法?PHP Generator::init怎么用?PHP Generator::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_get_contents
$template = file_get_contents('controller.tpl', true);
$template = str_replace('{$class_name}', $class_name, $template);
// Create the controller
$file = fopen(BASE_PATH . '/../app/controllers/' . $name . '_controller.php', 'w');
fwrite($file, $template);
fclose($file);
// Create the folder
mkdir(BASE_PATH . '/../app/views/' . strtolower($name));
echo "\nCreated the controller " . $class_name . " in\n";
echo realpath(dirname(BASE_PATH . '/../app/controllers/')) . '/controllers/' . $name . '_controller.php' . "\n\n";
}
}
// Generate a model
public static function model($name)
{
if (file_exists(BASE_PATH . '/../app/models/' . $name . '.php')) {
echo "\nThe model " . $name . " already exists in\n" . realpath(dirname(BASE_PATH . '/../app/models/')) . '/models/' . $name . '.php' . "\n\n";
} else {
$class_name = ucfirst($name);
$template = file_get_contents('model.tpl', true);
$template = str_replace('{$class_name}', $class_name, $template);
$file = fopen(BASE_PATH . '/../app/models/' . $name . '.php', 'w');
fwrite($file, $template);
fclose($file);
echo "\nCreated the model " . $class_name . " in\n";
echo realpath(dirname(BASE_PATH . '/../app/models/')) . '/models/' . $name . '.php' . "\n\n";
}
}
}
Generator::init();
示例2: realpath
//
$g_cwd = realpath(dirname($_SERVER['PHP_SELF']));
echo " CWD = " . $g_cwd . "\n";
//
// Load, instantiate, and configure the smarty template engine.
//
echo " - Loading Smarty...\n";
$tpl = new Smarty();
$tpl->template_dir = $g_cwd . "/templates";
$tpl->compile_dir = $g_cwd . "/templates_c";
$tpl->clear_all_cache();
// By default we assume that the root of the Torque SDK
// is located two folders up from the CWD. That is unless
// another path is passed in the command line.
$torqueRoot = "../..";
if ($argc >= 3) {
$torqueRoot = str_replace("\\", "/", $argv[2]);
}
// Kick off the generator
Generator::init($torqueRoot);
// Ready to read our config file.
echo " - Loading config file " . realpath($argv[1]) . "\n";
require $argv[1];
// Generate all projects
Generator::generateProjects($tpl);
// Now the solutions (if any)
$tpl->clear_all_cache();
Generator::generateSolutions($tpl);
// finally write out the sample.html for web deployment (if any)
WebPlugin::writeSampleHtml();
exit;