關於Luthier CI 命名行模式
感謝Luthier CI,您可以通過命令列介面(CLI)利用框架提供的各種可能性。
CLI路由的語法類似於HTTP和AJAX路由。必須在application/routes/cli.php檔案中定義CLI路由
例:
<?php # application/routes/cli.php // Using anonymous functions Route::cli('test', function(){ // <- (note that here the method is 'cli' and not 'get', 'post', etc.) echo 'Hello world!'; }); // Pointing to an existing controller Route::cli('test2', 'foo@bar'); 複製程式碼
CLI路由共享與HTTP / AJAX對應的相同屬性,您可以在此處瞭解有關它們的更多資訊。
CLI路由共享與HTTP / AJAX對應的相同屬性,您可以在此處瞭解有關它們的更多資訊。
例:
$ php path/to/app/index.php [segment1] [segument2] ... [segmentN] 複製程式碼
所以,有這條路線:
Route::cli('make/controller/{name}', function($name){ echo 'Making the controller ' . $name ; }); 複製程式碼
它可以通過執行訪問:
$ php path/to/app/index.php make controller test 複製程式碼
結果將是:
Making the controller test 複製程式碼
從版本0.2.0開始,Luthier CI附帶了幾個命令列工具,可以幫助您完成一些重複性任務。
寫入許可權 確保該application資料夾具有寫入許可權,以便這些命令正常工作
僅適用於開發 出於安全原因,如果您的應用程式配置了testing或production環境 ,則將禁用這些命令
預設情況下禁用CLI工具。要啟用它們,只需在路線檔案中新增幾行
<?php # application/routes/cli.php Luthier\Cli::maker();// 'luthier make' command Luthier\Cli::migrations(); // 'luthier migrate' command 複製程式碼
luthier make command
這允許生成各種各樣的框架檔案。
句法:
$ php index.php luthier make [resource] [name] [type?(sequenatial|date)=date] 複製程式碼
其中resource是資源的型別(controller,model,helper,library,middleware或migration),name是資源的名稱和type(在建立遷移的情況下)被遷移以產生型別。
例子:
// Creating a controller: $ php index.php luthier make controller ControllerName // Creating a model: $ php index.php luthier make model ModelName // Creating a library: $ php index.php luthier make library LibraryName // Creating a helper: $ php index.php luthier make helper HelperName // Creating a middleware: $ php index.php luthier make middleware MiddlewareName // Creating a migration (by default, migrations are created by date) $ php index.php luthier make migration create_users_table $ php index.php luthier make migration create_users_table date $ php index.php luthier make migration create_users_table sequential 複製程式碼
luthier migrate command
執行(或回滾)遷移。
句法
$ php index.php luthier migrate [version?=latest] 複製程式碼
version要執行的遷移的版本在哪裡。如果省略,它將繼續遷移到最新的可用版本。
也可以使用以下特殊值之一version:
reverse refresh
例子:
$ php index.php luthier migrate reverse $ php index.php luthier migrate refresh 複製程式碼