我尝试使用Symfony / Process组件为linux执行独立的chromedriver。这是项目的文件夹结构:
.
├── bin
│ └── chromedriver-linux
├── composer.json
├── index.php
└── vendor
在index.php
中,这是我尝试执行的代码:
<?php
require 'vendor/autoload.php';
use Symfony\Component\Process\Process;
$process = new Process(
[realpath(__DIR__.'/bin/chromedriver-linux')], null, ['DISPLAY' => ':0']
);
$process->start();
if (!$process->isSuccessful()) {
throw new \Symfony\Component\Process\Exception\ProcessFailedException($process);
}
然而情况更糟。现在没有错误输出,只是抛出一个Exception,如:
Fatal error: Uncaught Symfony\Component\Process\Exception\ProcessFailedException: The command "'/home/vagrant/Code/development/test-project/bin/chromedriver-linux'" failed. Exit Code: () Working directory: /home/vagrant/Code/development/dusk-2.0 Output: ================ Error Output: ================ in /home/vagrant/Code/development/test-project/index.php on line 14