code: protected function execute( $command, $failOnError = true, Logger $logger )
      {
          $descriptors = array(
              0 => array( 'pipe', 'r' ), // STDIN
              1 => array( 'pipe', 'w' ), // STDOUT
              2 => array( 'pipe', 'w' ), // STDERR
          );
  
          $proc = proc_open( $command, $descriptors, $pipes );
          if ( !is_resource( $proc ) )
          {
              $logger->log( 'Could not start processs.', Logger::ERROR );
              return Executor::ERROR;
          }
  
          // Add command output as information to log
          $output = trim( stream_get_contents( $pipes[1] ) );
          if ( !empty( $output ) )
          {
              $logger->log( $output );
          }
          fclose( $pipes[1] );
  
          // Add command error output as warnings to log
          $output = trim( stream_get_contents( $pipes[2] ) );
          if ( !empty( $output ) )
          {
              $logger->log( $output, Logger::WARNING );
          }
          fclose( $pipes[2] );
  
          // Receive process return values
          $return = proc_close( $proc );
          $logger->log( "Command exited with return value $return" );
  
          return ( $return && $failOnError ) ? Executor::ERROR : Executor::SUCCESS;
      }
docs: Execute command
  
  Execute given shell command. All error output from the shell command
  will be added as warnings to the logger.
  
  If the command returns with an non-zero exit code and $failOnError is
  set to true the command will return Executor::ERROR - otherwise
  it will always return with Executor::SUCCESS.
  
  @param string $command
  @param bool $failOnError
  @param Logger $logger
  @return int