1. [命令行](https://www.kancloud.cn/manual/thinkphp5/122951)
2. [创建自定义命令行](https://www.kancloud.cn/manual/thinkphp5/235129)
~~~
D:\phpStudy\WWW\workspace\DragonApi>php think
Think Console version 0.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-V, --version Display this console version
-q, --quiet Do not output any message
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
build Build Application Dirs
clear Clear runtime file
help Displays help for a command
list Lists commands
make
make:controller Create a new resource controller class
make:model Create a new model class
optimize
optimize:autoload Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
optimize:config Build config and common file cache.
optimize:route Build route cache.
optimize:schema Build database schema cache.
D:\phpStudy\WWW\workspace\DragonApi>php think -V
Think Console version 0.1
D:\phpStudy\WWW\workspace\DragonApi>php think -h
Usage:
help [options] [--] [<command_name>]
Arguments:
command The command to execute
command_name The command name [default: "help"]
Options:
--raw To output raw command help
-h, --help Display this help message
-V, --version Display this console version
-q, --quiet Do not output any message
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
The help command displays help for a given command:
php think help list
To display the list of available commands, please use the list command.
D:\phpStudy\WWW\workspace\DragonApi>php think -h list
Usage:
list [options] [--] [<namespace>]
Arguments:
namespace The namespace name
Options:
--raw To output raw command list
Help:
The list command lists all commands:
php think list
You can also display the commands for a specific namespace:
php think list test
It's also possible to get raw list of commands (useful for embedding command runner):
php think list --raw
D:\phpStudy\WWW\workspace\DragonApi>php think list
Think Console version 0.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-V, --version Display this console version
-q, --quiet Do not output any message
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
build Build Application Dirs
clear Clear runtime file
help Displays help for a command
list Lists commands
make
make:controller Create a new resource controller class
make:model Create a new model class
optimize
optimize:autoload Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
optimize:config Build config and common file cache.
optimize:route Build route cache.
optimize:schema Build database schema cache.
D:\phpStudy\WWW\workspace\DragonApi>php think test
TestCommand:
~~~
在 index 模块下创建 `Crontask` 类
~~~
<?php
namespace app\index\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class Crontask extends Command
{
protected function configure()
{
$this->setName('scanuid')
->setDescription('Baned Account and Unable Talked Account unsealed');
}
protected function execute(Input $input, Output $output)
{
$output->writeln("TestCommand:1");
}
}
~~~
通过 CLI 命令
~~~
php think scanuid
~~~
测试 `scanuid` 任务
~~~
D:\phpStudy\WWW\workspace\DragonApi>php think scanuid
TestCommand:1
~~~
- 目录
- 5.0.10环境配置
- 5.0.10控制器模型对象
- 5.0.10模型初始化
- 5.0.10定义数据对象
- 5.0.10创建数据对象data()方法
- 5.0.10创建数据对象-setAttr方法
- 5.0.10创建数据对象__set()方法
- 5.0.10查询数据对象getData()
- 实例
- 5.0.10保存数据save()方法
- 5.0.10保存数据saveAll()
- 5.0.10更新数据save()
- 5.0.10批量更新数据saveAll()
- 5.0.10删除数据delete()
- 5.0.10删除数据destroy()
- 5.0.10traits详解
- ThinkPHP 5.0 速查表
- 注释
- 环境变量配置
- Model分层
- MVC 逻辑服务数据
- Model分层及多对多关联的建立
- 控制器调用逻辑层
- Session
- 子域名session共享
- 系统错误
- 版本错误
- 返回错误
- Token令牌及身份识别
- 关联查询
- 安装
- Git安装
- Composer
- 扩展
- Composer类
- 非Composer类
- 引用第三方库
- 自定义命令行
- 计划任务
- 调试
- 调试模式
- 监听SQL
- 数据库调试
- 单元测试
- 初始化
- 控制器初始化
- 模型初始化
- 数据缓存
- 实战
- 版本升级
- 从V5.0.17升级到V5.0.18