diff --git a/composer.json b/composer.json index 7563688..1db1ad8 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "phpcasperjs/phpcasperjs", + "name": "mihail-shumilov/phpcasperjs", "description": "Simple PHP wrapper for CasperJS", - "homepage": "https://github.com/alwex/php-casperjs", + "homepage": "https://github.com/mihailShumilov/php-casperjs", "keywords": ["phpunit", "test", "browser"], "type": "library", "license": "MIT", diff --git a/src/Casper.php b/src/Casper.php index e5fec51..1fa9a6f 100644 --- a/src/Casper.php +++ b/src/Casper.php @@ -36,6 +36,16 @@ class Casper private $statusText = ''; private $cookies = []; + private $proxy = [ + 'host' => false, + 'port' => false, + 'type' => 'manual', + 'user' => false, + 'pass' => false + ]; + + private $proxyIsSet = false; + public function __construct($path2casper = null, $tempDir = null) { if ($path2casper) { @@ -104,6 +114,24 @@ public function setUserAgent($userAgent) $this->userAgent = $userAgent; } + /** + * Add proxy usage + * + * @param $host + * @param $port + * @param string $type + * @param string $user + * @param string $pass + */ + public function setProxy($host, $port, $type = 'manual', $user = '', $pass = '') { + $this->proxyIsSet = true; + $this->proxy['host'] = $host; + $this->proxy['port'] = $port; + $this->proxy['type'] = $type; + $this->proxy['user'] = $user; + $this->proxy['pass'] = $pass; + } + /** * enable debug logging into syslog * @@ -205,10 +233,23 @@ public function start($url) }); casper.userAgent('$this->userAgent'); + +FRAGMENT; + + if($this->proxyIsSet){ + $fragment .= <<proxy['host']}','{$this->proxy['port']}','{$this->proxy['type']}','{$this->proxy['user']}','{$this->proxy['pass']}'); +FRAGMENT; + + } + + $fragment .= <<