ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
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 ~~~