Skip to content

Commit ce9a5d8

Browse files
Limon MonteMASNathan
authored andcommitted
Add ability to set custom path to PhantomJS binary (#60)
* Add ability to set custom path to PhantomJS binary * Fix setBinPath() to support Windows, phantomjs.exe
1 parent e1ccc00 commit ce9a5d8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Capture.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@ private function getTemplateResult($templateName, array $args)
177177
return ob_get_clean();
178178
}
179179

180+
/**
181+
* Sets the path to PhantomJS binary, example: "/usr/bin"
182+
*
183+
* @param string $path
184+
*/
185+
public function setBinPath($binPath)
186+
{
187+
$binPath = rtrim($binPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
188+
if (!file_exists($binPath . 'phantomjs') && !file_exists($binPath . 'phantomjs.exe')) {
189+
throw new \Exception("Bin directory should contain phantomjs or phantomjs.exe file!");
190+
}
191+
$this->binPath = $binPath;
192+
}
193+
180194
/**
181195
* Sets the url to screenshot
182196
*

0 commit comments

Comments
 (0)