控制器里如何利用exec调用自定义命令吗

864328615

问题描述

自定义命令只能在根目录执行,请问入如何在控制里调用自定义命令呢,/usr/local/bin/php /Users/destiny/admin/transfer-statistics1/app/webman AsyncMysqlToElasticsearch 这边调用会报错

324 2 0
2个回答

TM

塞进去就可以了https://www.workerman.net/plugin/12

  • 暂无评论
yzh52521
global $cli;
$command    = $cli->find('命令');
$greetInput = new ArrayInput([]);
$output     = new BufferedOutput();
$command->run($greetInput, $output);
$exception = $output->fetch();
  • 864328615 2023-08-21

    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('同步服务正在进行中...');

  • 864328615 2023-08-21

    我是这么写的大大佬

  • yzh52521 2023-08-21

    能运行就行

🔝