factory() public static method

public static factory ( $phpcli = NULL )
Example #1
0
 /**
  * @param string          $path
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function binaryInstallWindows($path, InputInterface $input, OutputInterface $output)
 {
     $php = Engine::factory();
     $table = new Table($output);
     $table->setRows([['<info>' . $php->getName() . ' Path</info>', $php->getPath()], ['<info>' . $php->getName() . ' Version</info>', $php->getVersion()], ['<info>Compiler</info>', $php->getCompiler()], ['<info>Architecture</info>', $php->getArchitecture()], ['<info>Thread safety</info>', $php->getZts() ? 'yes' : 'no'], ['<info>Extension dir</info>', $php->getExtensionDir()], ['<info>php.ini</info>', $php->getIniPath()]])->render();
     $inst = Install::factory($path);
     $progress = $this->getHelperSet()->get('progress');
     $inst->setProgress($progress);
     $inst->setInput($input);
     $inst->setOutput($output);
     $inst->install();
     $deps_handler = new Windows\DependencyLib($php);
     $deps_handler->setProgress($progress);
     $deps_handler->setInput($input);
     $deps_handler->setOutput($output);
     $helper = $this->getHelperSet()->get('question');
     $cb = function ($choices) use($helper, $input, $output) {
         $question = new ChoiceQuestion('Multiple choices found, please select the appropriate dependency package', $choices);
         $question->setMultiselect(false);
         return $helper->ask($input, $output, $question);
     };
     foreach ($inst->getExtDllPaths() as $dll) {
         if (!$deps_handler->resolveForBin($dll, $cb)) {
             throw new \Exception('Failed to resolve dependencies');
         }
     }
 }
Example #2
0
 protected function prepare()
 {
     $engine = Engine::factory();
     if (Type::determinePecl($this->path, $matches) < 1) {
         throw new \Exception('Not valid PECL URI');
     }
     if ('php' != $engine->getName()) {
         throw new \Exception('PECL is only supported with PHP');
     }
     $this->name = $matches['package'];
     $this->url = 'https://pecl.php.net/get/' . $matches['package'];
     if (isset($matches['stability']) && '' !== $matches['stability']) {
         $this->stability = $matches['stability'];
         $this->url .= '-' . $matches['stability'];
     } else {
         $this->stability = 'stable';
     }
     if (isset($matches['version']) && '' !== $matches['version']) {
         $this->url .= '/' . $matches['version'];
         $this->prettyVersion = $matches['version'];
         $this->version = $matches['version'];
     } else {
         $this->version = 'latest';
         $this->prettyVersion = 'latest-' . $this->stability;
     }
 }
Example #3
0
 /**
  * @param string $ext
  */
 public function __construct($ext)
 {
     // used only if only the extension name is given
     if (strpos('//', $ext) !== false) {
         $this->extensionPeclExists();
     }
     $this->extName = $ext;
     $this->php = Engine::factory();
 }
Example #4
0
 public static function factory(Interfaces\Package\Convey\Command $command)
 {
     $engine = Engine::factory();
     switch ($engine->getName()) {
         case 'php':
             return new PHP\Convey\Command\DefaultExecutor($command);
         case 'hhvm':
             return new HHVM\Convey\Command\DefaultExecutor($command);
     }
     return new self($command);
 }
Example #5
0
 public static function factory($path, $cb)
 {
     $engine = Engine::factory();
     switch ($engine->getName()) {
         case 'php':
             return new PHP\Command\Validate($path, $cb);
         case 'hhvm':
             throw new \Exception("Not implemented for engine '{$engine->getName()}'");
         default:
             throw new \Exception("Unsupported engine '{$engine->getName()}'. Implement it!");
     }
 }
Example #6
0
 public static function factory($path)
 {
     $engine = Engine::factory();
     switch ($engine->getName()) {
         case 'php':
             if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                 return new PHP\Command\Install\Windows\Binary($path);
             } else {
                 throw new \Exception('On Unix Build::factory() functionality should be used to implememnt installation, ' . 'except you really need to install a binary.');
             }
         case 'hhvm':
             throw new \Exception("Not implemented for engine '{$engine->getName()}'");
         default:
             throw new \Exception("Unsupported engine '{$engine->getName()}'. Implement it!");
     }
 }
Example #7
0
 public static function factory($name, $version, $prettyVersion, $force = false)
 {
     if (self::deliverFresh($force)) {
         $engine = Engine::factory();
         switch ($engine->getName()) {
             case 'php':
                 self::$instance = new PHP\Package($name, $version, $prettyVersion);
                 break;
             case 'hhvm':
                 self::$instance = new HHVM\Package($name, $version, $prettyVersion);
                 break;
             default:
                 throw new \Exception("Unsupported engine '{$engine->getName()}'. Implement it!");
         }
     }
     return self::$instance;
 }
Example #8
0
 public static function factory(Interfaces\Engine $engine = null)
 {
     if (null == self::$instance) {
         $engine = null == $engine ? \Pickle\Engine::factory() : $engine;
         switch ($engine->getName()) {
             case 'php':
                 self::$instance = new PHP\Ini($engine);
                 break;
             case 'hhvm':
                 self::$instance = new HHVM\Ini($engine);
                 break;
             default:
                 throw new \Exception("Unsupported engine '{$engine->getName()}'");
         }
     }
     return self::$instance;
 }
Example #9
0
 public static function factory($path, $cb, $noConvert = false, $binary = false)
 {
     $engine = Engine::factory();
     switch ($engine->getName()) {
         case 'php':
             if ($binary) {
                 if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                     return new PHP\Command\Release\Windows\Binary($path, $cb, $noConvert);
                 } else {
                     throw new \Exception('Binary packaging not implemented for this platform, use the build system of your favourite package manager');
                 }
             } else {
                 return new PHP\Command\Release($path, $cb, $noConvert);
             }
         case 'hhvm':
             throw new \Exception("Not implemented for engine '{$engine->getName()}'");
         default:
             throw new \Exception("Unsupported engine '{$engine->getName()}'. Implement it!");
     }
 }
Example #10
0
 public static function factory(Interfaces\Package $package, $optionValue)
 {
     $engine = Engine::factory();
     switch ($engine->getName()) {
         case 'php':
             if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                 return new PHP\Command\Build\Windows($package, $optionValue);
             } else {
                 return new PHP\Command\Build\Unix($package, $optionValue);
             }
         case 'hhvm':
             if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                 throw new \Exception("Not implemented for engine '{$engine->getName()} on Windows'");
             } else {
                 return new HHVM\Command\Build\Unix($package, $optionValue);
             }
         default:
             throw new \Exception("Unsupported engine '{$engine->getName()}'. Implement it!");
     }
 }
Example #11
0
 protected function updateIni()
 {
     $ini = \Pickle\Engine\Ini::factory(\Pickle\Engine::factory());
     $ini->updatePickleSection(array($this->pkg->getName()));
 }
Example #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = rtrim($input->getArgument('path'), '/\\');
     Util\TmpDir::set($input->getOption('tmp-dir'));
     /* Respect the --php option. This will setup the engine instance. */
     $php = Engine::factory($input->getOption('php'));
     /* if windows, try bin install by default */
     if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
         $sourceRequested = $input->getOption('source');
         if (!$sourceRequested) {
             $this->binaryInstallWindows($path, $input, $output);
             return 0;
         }
     }
     $package = $this->getHelper('package')->convey($input, $output, $path);
     /* TODO Info package command should be used here. */
     $this->getHelper('package')->showInfo($output, $package);
     list($optionsValue, $force_opts) = $this->buildOptions($package, $input, $output);
     if ($input->getOption('dry-run')) {
         return 0;
     }
     $this->sourceInstall($package, $input, $output, $optionsValue, $force_opts);
     return 0;
 }
Example #13
0
 public function install()
 {
     $backCwd = getcwd();
     chdir($this->tempDir);
     /* Record the produced DLL filenames. */
     $files = (array) glob("*/*/php_*.dll");
     $files = array_merge($files, glob("*/php_*.dll"));
     $dlls = [];
     foreach ($files as $file) {
         $dlls[] = basename($file);
     }
     $res = $this->runCommand('nmake install');
     chdir($backCwd);
     if (!$res) {
         throw new \Exception('nmake install failed');
     }
     $ini = \Pickle\Engine\Ini::factory(Engine::factory());
     $ini->updatePickleSection($dlls);
 }