api\application\command.php 添加
return [ 'test' => 'app\common\command\Xxx', ];
G:\phpstudy_pro\WWW\lzl\api>php think image
<?php
namespace app\index\command;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
class CronImage extends Command
{
protected function configure()
{
$this->addArgument('type', Argument::REQUIRED); //必传参数
//$this->addArgument('type', Argument::OPTIONAL);//可选参数
$this->setName('CronImage')->setDescription("设置图片表测试数据");//setName与文件名称保持一致 setDEscription则是说明
}
/**
* 业务逻辑
* @param Input $input
* @param Output $output
* @return int|void|null
*/
protected function execute(Input $input, Output $output)
{
$output->writeln('type value');
$type = $input->getArgument('type');
switch($type)
{
case 1:
echo 1;
break;
case 2:
echo '2-';
break;
}
}
}执行:php think CornImage 1