當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Generator::init方法代碼示例

本文整理匯總了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();
開發者ID:BaylorRae,項目名稱:Borealis-MVC-bk,代碼行數:30,代碼來源:generate.php

示例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;
開發者ID:RasterCode,項目名稱:Torque3D,代碼行數:31,代碼來源:projectGenerator.php


注:本文中的Generator::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。