public function run(InputInterface $input, OutputInterface $output)
    {
        try {

            $executable = $this->write(
                $this->compile($input)
            );

            $descriptorspec = array(
                array('pipe', 'r'),
                array('pipe', 'w'),
                array('pipe', 'w')
            );

            $process = proc_open(escapeshellcmd(sprintf('%s %s', $this->engine->getCommand(), $executable)), $descriptorspec, $pipes, null, null);

            if (!is_resource($process)) {
                throw new ProcedureFailedException('proc_open() did not return a resource');
            }

            $result = stream_get_contents($pipes[1]);
            $log    = stream_get_contents($pipes[2]);

            fclose($pipes[0]);
            fclose($pipes[1]);
            fclose($pipes[2]);

            proc_close($process);

            $output->import(
                $this->parser->parse($result)
            );

            $this->engine->log($log);

            $this->remove($executable);

        } catch (NotWritableException $e) {
            throw $e;
        } catch (\Exception $e) {

            if (isset($executable)) {
                $this->remove($executable);
            }

            throw new ProcedureFailedException(sprintf('Error when executing PhantomJs procedure - %s', $e->getMessage()));
        }
    }
public function run(InputInterface $input, OutputInterface $output)
    {
        try {

            $executable = $this->write(
                $this->compile($input)
            );

            $descriptorspec = array(
                array('pipe', 'r'),
                array('pipe', 'w'),
                array('pipe', 'w')
            );

            $process = proc_open(escapeshellcmd(sprintf('%s %s', $this->engine->getCommand(), $executable)), $descriptorspec, $pipes, null, null);

            if (!is_resource($process)) {
                throw new ProcedureFailedException('proc_open() did not return a resource');
            }

            $result = stream_get_contents($pipes[1]);
            $log    = stream_get_contents($pipes[2]);

            fclose($pipes[0]);
            fclose($pipes[1]);
            fclose($pipes[2]);

            proc_close($process);

            $output->import(
                $this->parser->parse($result)
            );

            $this->engine->log($log);

            $this->remove($executable);

        } catch (NotWritableException $e) {
            throw $e;
        } catch (\Exception $e) {

            if (isset($executable)) {
                $this->remove($executable);
            }

            throw new ProcedureFailedException(sprintf('Error when executing PhantomJs procedure - %s', $e->getMessage()));
        }
    }
public function run ( InputInterface $ input , OutputInterface $ output ) { try { $ executable = $ this -> write ( $ this -> compile ( $ input ) ) ; $ descriptorspec = array ( array ( 'pipe' , 'r' ) , array ( 'pipe' , 'w' ) , array ( 'pipe' , 'w' ) ) ; $ process = proc_open ( escapeshellcmd ( sprintf ( '%s %s' , $ this -> engine -> getCommand ( ) , $ executable ) ) , $ descriptorspec , $ pipes , null , null ) ; if ( ! is_resource ( $ process ) ) { throw new ProcedureFailedException ( 'proc_open() did not return a resource' ) ; } $ result = stream_get_contents ( $ pipes [ 1 ] ) ; $ log = stream_get_contents ( $ pipes [ 2 ] ) ; fclose ( $ pipes [ 0 ] ) ; fclose ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 2 ] ) ; proc_close ( $ process ) ; $ output -> import ( $ this -> parser -> parse ( $ result ) ) ; $ this -> engine -> log ( $ log ) ; $ this -> remove ( $ executable ) ; } catch ( NotWritableException $ e ) { throw $ e ; } catch ( \ Exception $ e ) { if ( isset ( $ executable ) ) { $ this -> remove ( $ executable ) ; } throw new ProcedureFailedException ( sprintf ( 'Error when executing PhantomJs procedure - %s' , $ e -> getMessage ( ) ) ) ; } }
Run procedure.

@access public
@param  \JonnyW\PhantomJs\Procedure\InputInterface           $input
@param  \JonnyW\PhantomJs\Procedure\OutputInterface          $output
@throws \JonnyW\PhantomJs\Exception\ProcedureFailedException
@throws \JonnyW\PhantomJs\Exception\NotWritableException
@return void
Run procedure .