/** * URL of the PhantomJS distribution for the installing * * @param string $version * @return string * @throws \Canterville\RuntimeException */ protected function getUrl($version) { $url = 'http://download.slimerjs.org/releases/0.9.6/slimerjs-' . $version; $os = Helpers::getOS(); switch ($os) { case Helpers::OS_WINDOWS: $url .= '-win32.zip'; break; case Helpers::OS_LINUX: $bitSize = Helpers::getBitSize(); switch ($bitSize) { case Helpers::BIT_32: $url .= '-linux-i686.tar.bz2'; break; case Helpers::BIT_64: $url .= '-linux-x86_64.tar.bz2'; break; default: // bit size unknown $url = false; } break; case Helpers::OS_MAC: $url .= '-mac.tar.bz2'; break; default: // OS unknown $url = false; } if ($url === false) { $msg = 'The Installer could not select a SlimerJS package for this OS.' . 'Please install SlimerJS manually into the "/vendor/bin" folder of your project.'; throw new RuntimeException($msg); } return $url; }
/** * Returns command for run * * @param string $filename * @return string */ private function getCommand($filename) { $commands = []; // Canterville binaries has higher priority as user binaries $commands[] = 'export PATH=' . $this->getBinDir() . ':$PATH'; // SlimJS required set path to Firefox if ($this->getOption('engine') === self::ENGINE_SLIMMERJS) { switch (Helpers::getOS()) { case Helpers::OS_MAC: $commands[] = 'export SLIMERJSLAUNCHER=/Applications/Firefox.app/Contents/MacOS/firefox'; break; case Helpers::OS_WINDOWS: $commands[] = 'SET SLIMERJSLAUNCHER="c:\\Program Files\\Mozilla Firefox\\firefox.exe'; break; case Helpers::OS_LINUX: $commands[] = 'export SLIMERJSLAUNCHER=/usr/bin/firefox'; break; } } // run script on CasperJS with options $options = $this->getCommandOptions(); $commands[] = 'casperjs ' . $filename . $options; return implode(';', $commands); }