【发布时间】:2020-08-06 19:34:38
【问题描述】:
Symfony 组件进程
/**
* @param array $command The command to run and its arguments listed as separate entries
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
* @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input
* @param int|float|null $timeout The timeout in seconds or null to disable
*
* @throws LogicException When proc_open is not installed
*/
public function __construct($command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
{ .. }
我创建了一个命令,并在我的控制器中使用组件 Process。
当我尝试运行 Process 时,我得到一个 ProcessFailException
命令“app:load-file foo bar foobar”失败
退出代码:1(一般错误)
.. ErrorOutput:文件名、目录名或卷标语法不正确
use Symfony\Component\Process\Process;
..
public function loadFile(KernelInterface $kernel)
{
$argument1 = 'foo';
$argument2 = 'bar';
$argument3 = 'foobar';
$rootDir = $kernel->getProjectDir();
$process = new Process(array(
$rootDir . '/bin/console app:load-file',
$argument1,
$argument2,
$argument3
));
$process->mustRun();
}
从控制器运行命令的正确语法是什么?
/* *@param array $command 要运行的命令及其参数作为单独的条目列出
公共函数 __construct($command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
{ .. }
【问题讨论】:
标签: command-line command symfony4