自定义命令只能在根目录执行,请问入如何在控制里调用自定义命令呢,/usr/local/bin/php /Users/destiny/admin/transfer-statistics1/app/webman AsyncMysqlToElasticsearch 这边调用会报错
塞进去就可以了https://www.workerman.net/plugin/12
global $cli; $command = $cli->find('命令'); $greetInput = new ArrayInput([]); $output = new BufferedOutput(); $command->run($greetInput, $output); $exception = $output->fetch();
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput;
try { $input = new ArrayInput(array( 'name'=>'AsyncMysqlToElasticsearch' )); $output = new NullOutput(); $command = new AsyncMysqlToElasticsearch(); $command->run($input, $output); }catch (\Throwable $e){ return $this->error('同步出错'); } return $this->success('同步服务正在进行中...');
我是这么写的大大佬
能运行就行
塞进去就可以了https://www.workerman.net/plugin/12
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
try {
$input = new ArrayInput(array(
'name'=>'AsyncMysqlToElasticsearch'
));
$output = new NullOutput();
$command = new AsyncMysqlToElasticsearch();
$command->run($input, $output);
}catch (\Throwable $e){
return $this->error('同步出错');
}
return $this->success('同步服务正在进行中...');
我是这么写的大大佬
能运行就行