我有一个命令叫做:
broker:create-device
它接受2个命令行参数。当我通过命令行运行时,它起作用了。
现在,我想从控制器运行。因此,我阅读了我可以做的另一篇文章《 Stack Overflow》:
$process = new Process(['php bin/console broker:create-device',1,2]);
$process->run();
并且执行命令,日志仅显示弃用错误:
[2019-02-07 17:04:13] php.INFO: User Deprecated: The "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" class is deprecated since Symfony 4.2, use "Symfony\Component\Console\Command\Command" with dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand\" class is deprecated since Symfony 4.2, use \"Symfony\\Component\\Console\\Command\\Command\" with dependency injection instead. at /Users/myuser/Code/site/vendor/symfony/framework-bundle/Command/ContainerAwareCommand.php:18)"} []
但是,execute中的实际代码未运行。有什么想法吗?
答案 0 :(得分:0)
似乎每个地方都需要分开,而不仅仅是争论……
因此,以上过程已编辑为
$ process = new Process(['php','bin / console','broker:create-device',1,2]);