Ejemplo n.º 1
0
 public function start()
 {
     if (is_null($this->save_path)) {
         $this->save_path = GlobalMas::$filesPath_absolute . 'phantomjs/snap.png';
     } else {
         if ($this->save_path[0] != "/") {
             $this->save_path = GlobalMas::$filesPath_absolute . 'phantomjs/' . $this->save_path;
         }
     }
     //---------------------------------------------
     //FileFolder::createFolderStructure($this->save_path);
     //---------------------------------------------
     return Phantomjs::callScript("snapShot.js", array($this->url, $this->save_path, $this->selector, $this->dur, $this->snaps));
 }
Ejemplo n.º 2
0
 /**
  * Start a new phantomjs server, optionally provide pid_file and log file.
  * If you provide a pid_file, it will kill the process currently running on that pid, before starting the new one
  * If the start is unsuccessfull it will return FALSE
  * @param  string $pid_file
  * @param  string $log_file
  * @return boolean
  */
 public function start($pid_file = NULL, $log_file = '/dev/null')
 {
     if ($pid_file) {
         $this->_pid_file = $pid_file;
         if (is_file($this->_pid_file)) {
             Phantomjs::kill(file_get_contents($pid_file));
             unlink($this->_pid_file);
         }
     }
     $this->_pid = Phantomjs::start('phantom.js', $this->port(), 'phantomjs-connection.js', $log_file);
     if ($this->_pid_file) {
         file_put_contents($this->_pid_file, $this->_pid);
     }
     $self = $this;
     return Attempt::make(function () use($self) {
         return $self->is_running();
     });
 }