1

我有一个使用 symfony3 的应用程序,一些客户使用它。我计划通过在线下载补丁代码来修复错误。

但是要知道,当补丁代码覆盖工程代码时,必须执行以下命令才能使补丁代码生效。

php php bin/console cache:clear --env=prod chmod -R 777 var/tmp

不幸的是,这个命令只能在cli模式下执行;

我该如何实现这个功能?

最后,请原谅我英语不好。:简单:

4

1 回答 1

0

You can use Symfony Process Component to achieve this:

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

$process = new Process('php bin/console cache:clear --env=prod && chmod -R 777 var/tmp');
$process->run();

// executes after the command finishes
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}

echo $process->getOutput();

You have multiple solutions in fact:

  • Implement this code in a controller only accessible by you.
  • If you use a deployer like capistrano, ansible or any other technology, just add the cli command you want to execute and trigger execution after deploying the patch.

you can also create a Symfony Command to wrap you cli commands

于 2018-07-10T05:34:12.047 回答