/**
  * Initalized command
  *
  * @throws \RuntimeException
  */
 protected function initialize()
 {
     parent::initialize();
     $editorCmd = getenv('EDITOR');
     if (empty($editorCmd)) {
         throw new \RuntimeException('No $EDITOR environment variable set');
     }
     $this->parse($editorCmd);
 }
Beispiel #2
0
 public function process($input_file, $output_file = false, $format = ["pdf"], $parameters = [], $dataSource = '', $dataSourceParams = [], $background = true, $redirect_output = true)
 {
     if (is_null($input_file) || empty($input_file)) {
         throw new \Exception("No input file", 1);
     }
     if (is_array($format)) {
         foreach ($format as $key) {
             if (!in_array($key, $this->formats)) {
                 throw new \Exception("Invalid format!", 1);
             }
         }
     } else {
         if (!in_array($format, $this->formats)) {
             throw new \Exception("Invalid format!", 1);
         }
     }
     $cb = new CommandBuilder($this->executable);
     $this->theCommand = $cb->input($input_file)->output($output_file)->format($format)->addParams($parameters)->dataSource($dataSource)->query($dataSourceParams);
     $this->redirectOutput = $redirect_output;
     $this->background = $background;
     return $this;
 }
Beispiel #3
0
 /**
  * Initalized command
  */
 protected function initialize()
 {
     parent::initialize();
     $arguments = $_SERVER['argv'];
     // Check if command is run inside PHAR
     if (\Phar::running()) {
         // PHAR version
         $this->setCommand(array_shift($arguments));
     } elseif (!empty($_SERVER['_'])) {
         // Plain PHP version
         if ($_SERVER['argv'][0] !== $_SERVER['_']) {
             $this->setCommand($_SERVER['_']);
             $this->addArgument(reset($arguments));
         }
     }
     // Fallback
     if (!$this->getCommand()) {
         $this->setCommand('php');
         $this->addArgument($_SERVER['PHP_SELF']);
     }
 }
 /**
  * Initalized command
  */
 protected function initialize()
 {
     parent::initialize();
     $arguments = $_SERVER['argv'];
     if (\Phar::running()) {
         // running as phar
         $this->setCommand(array_shift($arguments));
     } elseif (!empty($_SERVER['_'])) {
         if ($_SERVER['argv'][0] !== $_SERVER['_']) {
             $this->setCommand($_SERVER['_']);
             $this->addArgument(array_shift($arguments));
         }
     }
     // Fallback
     if (!$this->getCommand()) {
         $this->setCommand('php');
         $this->addArgument($_SERVER['PHP_SELF']);
     }
     // All other arguments
     $this->addArgumentList($arguments);
 }
Beispiel #5
0
 public function configure(\PhpBrew\Build $build)
 {
     $variantBuilder = new VariantBuilder();
     $extra = $build->getExtraOptions();
     if (!file_exists('configure')) {
         $this->logger->debug("configure file not found, running buildconf script...");
         system('./buildconf') !== false or die('buildconf error');
     }
     // build configure args
     // XXX: support variants
     $cmd = new CommandBuilder('./configure');
     // putenv('CFLAGS=-O3');
     $prefix = $build->getInstallPrefix();
     $args[] = "--prefix=" . $prefix;
     $args[] = "--with-config-file-path={$prefix}/etc";
     $args[] = "--with-config-file-scan-dir={$prefix}/var/db";
     $args[] = "--with-pear={$prefix}/lib/php";
     // this is to support pear
     $build->enableVariant('xml');
     $variantOptions = $variantBuilder->build($build);
     if ($variantOptions) {
         $args = array_merge($args, $variantOptions);
     }
     $this->logger->debug('Enabled variants: ' . join(', ', array_keys($build->getVariants())));
     $this->logger->debug('Disabled variants: ' . join(', ', array_keys($build->getDisabledVariants())));
     if ($patchFiles = $this->options->patch) {
         foreach ($patchFiles as $patchFile) {
             // copy patch file to here
             $this->logger->info("===> Applying patch file from {$patchFile} ...");
             system("patch -p0 < {$patchFile}");
         }
     }
     // let's apply patch for libphp{php version}.so (apxs)
     if ($build->isEnabledVariant('apxs2')) {
         $apxs2Checker = new \PhpBrew\Tasks\Apxs2CheckTask($this->logger);
         $apxs2Checker->check($build);
         $apxs2Patch = new \PhpBrew\Tasks\Apxs2PatchTask($this->logger);
         $apxs2Patch->patch($build, $this->options);
     }
     foreach ($extra as $a) {
         $args[] = $a;
     }
     $cmd->args($args);
     $this->logger->info("===> Configuring {$build->version}...");
     $cmd->append = false;
     $cmd->stdout = Config::getVersionBuildLogPath($build->name);
     echo "\n\n";
     echo "Use tail command to see what's going on:\n";
     echo "   \$ tail -f {$cmd->stdout}\n\n\n";
     $this->logger->debug($cmd->getCommand());
     if ($this->options->nice) {
         $cmd->nice($this->options->nice);
     }
     $cmd->execute() !== false or die('Configure failed.');
     // Then patch Makefile for PHP 5.3.x on 64bit system.
     $currentVersion = preg_replace('/[^\\d]*(\\d+).(\\d+).*/i', '$1.$2', $this->version);
     if (Utils::support64bit() && version_compare($currentVersion, '5.3', '==')) {
         $this->logger->info("===> Applying patch file for php5.3.x on 64bit machine.");
         system('sed -i \'/^BUILD_/ s/\\$(CC)/\\$(CXX)/g\' Makefile');
         system('sed -i \'/EXTRA_LIBS = /s|$| -lstdc++|\' Makefile');
     }
 }