2015-02-08 100 views
0

我在我的Laravel项目中使用Symfony提供的进程组件:http://symfony.com/doc/current/components/process.htmlLaravel Symfony进程组件未能启动新进程

这里是我的代码:

$process = new Process('dir'); 
try 
{ 
    $process->mustRun(); 
    print $process->getOutput(); 
} catch (ProcessFailedException $e) { 
    print $e->getMessage(); 
} 

所以,没有什么花哨这里,只是一个菜谱的解决方案。但是,我收到以下错误:

The command "dir" failed. 
Exit Code: 1(General error) 

Output: 
================ 



Error Output: 
================ 

我找不出什么问题,因为日志中没有任何内容。如果重要,我在Windows Server 2008 R2上运行它。

+0

你得到任何下面的语句有什么不同:1)'$处理=新工艺( '目录',NULL,NULL,NULL,60,[ 'suppress_errors'=>假]);' ? 2)'$ process = new Process('dir',null,null,null,60,['suppress_errors'=> false,'bypass_shell'=> false]);'? 3)'$ process = new Process('dir'); $流程 - > setEnhanceWindowsCompatibility(假);'? – patricus 2015-02-08 22:39:41

+0

@patricus没有帮助。但是,最后一个(3)方法完全没有返回输出。 – none32 2015-02-09 20:33:18

回答

0

我有同样的问题,像@ none32面临。我尝试了@patricus建议的解决方案,它对我很有帮助。

$process->setEnhanceWindowsCompatibility(false);