Luthier CI 命令行 Command line

发布时间:2019-08-08 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Luthier CI 命令行 Command line脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

命令行 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)利用框架提供的各种可能性。

句法 Syntax

CLI路由的语法类似于HTTP和@L_126_9@路由。必须在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路由 Using CLI routes

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

内置CLI工具 Built-in CLI tools

从版本0.2.0开始,Luthier CI附带了几个命令行工具,可以帮助您完成一些重复性任务

写入权限

确保该application文件夹具有写入权限,以便这些命令正常工作

仅适用于开发

出于安全原因,如果您的应用程序配置了testing或PRoduction环境 ,则将禁用这些命令

激活 Activation

默认情况下禁用CLI工具。要激活它们,只需在路线文件中添加几行

<?php
# application/routes/cli.php

LuthierCli::maker();      // 'luthier make' command
LuthierCli::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

脚本宝典总结

以上是脚本宝典为你收集整理的Luthier CI 命令行 Command line全部内容,希望文章能够帮你解决Luthier CI 命令行 Command line所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。