感謝Luthier CI,您能夠經過命令行界面(CLI)利用框架提供的各類可能性。php
CLI路由的語法相似於HTTP和AJAX路由。必須在application/routes/cli.php文件中定義CLI路由安全
例:bash
<?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對應的相同屬性,您能夠在此處瞭解有關它們的更多信息。app
CLI路由共享與HTTP / AJAX對應的相同屬性,您能夠在此處瞭解有關它們的更多信息。框架
例:工具
$ php path/to/app/index.php [segment1] [segument2] ... [segmentN]
複製代碼
因此,有這條路線:post
Route::cli('make/controller/{name}', function($name){
echo 'Making the controller ' . $name ;
});
複製代碼
它能夠經過運行訪問:ui
$ php path/to/app/index.php make controller test
複製代碼
結果將是:spa
Making the controller test
複製代碼
從版本0.2.0開始,Luthier CI附帶了幾個命令行工具,能夠幫助您完成一些重複性任務。命令行
默認狀況下禁用CLI工具。要激活它們,只需在路線文件中添加幾行
<?php
# application/routes/cli.php
Luthier\Cli::maker(); // 'luthier make' command
Luthier\Cli::migrations(); // 'luthier migrate' 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
複製代碼
運行(或回滾)遷移。
句法
$ php index.php luthier migrate [version?=latest]
複製代碼
version要運行的遷移的版本在哪裏。若是省略,它將繼續遷移到最新的可用版本。
也能夠使用如下特殊值之一version:
reverse
: 撤消全部遷移refresh
: 撤消全部遷移,而後繼續遷移到最新的可用版本例子:
$ php index.php luthier migrate reverse
$ php index.php luthier migrate refresh
複製代碼