關於Luthier CI 命名行模式

命令行 Command line

內容 Contents

  1. 介紹 Introduction
  2. 句法 Syntax
  3. 使用CLI路由 Using CLI routes
  4. 內置CLI工具 Built-in CLI tools
    1. 激活 Activation
    2. 'luthier make'命令 'luthier make' command
    3. 'luthier migrate'命令 'luthier migrate' command

介紹 ( Introduction )

感謝Luthier CI,您能夠經過命令行界面(CLI)利用框架提供的各類可能性。php

Sintaxis

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路由 Using CLI routes

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
複製代碼

內置CLI工具 Built-in CLI tools

從版本0.2.0開始,Luthier CI附帶了幾個命令行工具,能夠幫助您完成一些重複性任務。命令行

寫入權限
確保該application文件夾具備寫入權限,以便這些命令正常工做
僅適用於開發
出於安全緣由,若是您的應用程序配置了testing或production環境 ,則將禁用這些命令

激活 Activation

默認狀況下禁用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
複製代碼
相關文章
相關標籤/搜索