1. [命令行](http://www.hmoore.net/manual/thinkphp5/122951)
2. [創建自定義命令行](http://www.hmoore.net/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