public function copyPhantomJsBinaryToBinFolder($targetDir, $binDir)
{
if (!is_dir($binDir)) {
mkdir($binDir);
}
$os = $this->getOS();
$sourceName = '/bin/phantomjs';
$targetName = $binDir . '/phantomjs';
if ($os === 'windows') {
// the suffix for binaries on windows is ".exe"
$sourceName .= '.exe';
$targetName .= '.exe';
/**
* The release folder structure changed between versions.
* For versions up to v1.9.8, the executables resides at the root.
* From v2.0.0 on, the executable resides in the bin folder.
*/
if (is_file($targetDir . '/phantomjs.exe')) {
$sourceName = str_replace('/bin', '', $sourceName);
}
// slash fix (not needed, but looks better on the dropped php file)
$targetName = str_replace('/', '\\', $targetName);
}
if ($os !== 'unknown') {
copy($targetDir . $sourceName, $targetName);
chmod($targetName, static::PHANTOMJS_CHMODE);
}
$this->dropClassWithPathToInstalledBinary($targetName);
}