application\common.php文件内容如下:
return [
'app\shell\command\Test',
];
application\shell\command\Test.php内容如下:
namespace app\shell\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
class Test extends Command
{
protected function configure()
{
parent::configure();
$this->setName('Test')->setDescription('Test');
}
protected function execute(Input $input, Output $output)
{
echo 'TestTestTestTest';exit;
}
}
切换到TP5根目录,即../application/上级目录(同级有个文件think)。
按住Shift键并且右击鼠标,选择‘在此处执行shell’。(或者直接cmd切换到该目录),执行如下命令:
F:\x\www\PHPTutorial\php\php-5.6.27-nts\php.exe .\think Test
注:Test与下面的名称必须一致
setName('Test')