1
如何使用symfony/console運行本機terminal command (e.g: bower)
?如何讓Symfony Console運行本機終端命令?
我在我的mac中安裝了bower
,並且可以從console
運行。但是現在我需要symfony/console來運行我的本地終端命令(例如:bower)。
如何做到這一點?
如何使用symfony/console運行本機terminal command (e.g: bower)
?如何讓Symfony Console運行本機終端命令?
我在我的mac中安裝了bower
,並且可以從console
運行。但是現在我需要symfony/console來運行我的本地終端命令(例如:bower)。
如何做到這一點?
您可以使用PHP的exec
函數。或者,如果您想要對其進行更多控制並以良好的方式讀取結果,則可以使用Symfony Process component:
exec('bower');
// or it's shortcut
`bower`;
// or the Process component
use Symfony\Component\Process\Process;
$bower = new Process('bower');
$bower->run();
// ... other nice things, like $bower->isSuccesful(), ->getOutput() & more