当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::create方法代码示例

本文整理汇总了PHP中Composer\Factory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::create方法的具体用法?PHP Factory::create怎么用?PHP Factory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Factory的用法示例。


在下文中一共展示了Factory::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Executes composer for the extension.
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $this->argument('extension');
     $update = $this->option('update');
     if (!is_dir($path = $this->pagekit['path.extensions'] . "/{$name}") && file_exists("{$path}/extension.json")) {
         $this->error("Extension not exists '{$path}'");
         exit;
     }
     $package = json_decode(file_get_contents("{$path}/extension.json"), true);
     if (!isset($package['composer']) || empty($package['composer'])) {
         $this->error("Composer not defined in '{$path}/extension.json'");
         exit;
     }
     $this->loadComposer($path);
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $composer = Factory::create($io, $package['composer']);
     $lockFile = new JsonFile("{$path}/extension.lock");
     $locker = new Locker($io, $lockFile, $composer->getRepositoryManager(), $composer->getInstallationManager(), md5(json_encode($package['composer'])));
     $composer->setLocker($locker);
     $installed = new JsonFile($this->pagekit['path'] . '/vendor/composer/installed.json');
     $internal = new CompositeRepository([]);
     $internal->addRepository(new InstalledFilesystemRepository($installed));
     $installer = Installer::create($io, $composer);
     $installer->setAdditionalInstalledRepository($internal);
     $installer->setUpdate($update);
     return $installer->run();
 }
开发者ID:RobertJGabriel,项目名称:pagekit,代码行数:30,代码来源:ExtensionComposerCommand.php

示例2: create

 /**
  * Create \Composer\Composer
  *
  * @return \Composer\Composer
  * @throws \Exception
  */
 public function create()
 {
     if (!getenv('COMPOSER_HOME')) {
         putenv('COMPOSER_HOME=' . $this->directoryList->getPath(DirectoryList::COMPOSER_HOME));
     }
     return \Composer\Factory::create(new BufferIO(), $this->composerJsonFinder->findComposerJson());
 }
开发者ID:mage2pro,项目名称:core,代码行数:13,代码来源:ComposerFactory.php

示例3: getComposer

 public function getComposer()
 {
     if ($this->composer === null) {
         $this->composer = Factory::create($this->io, null, false);
     }
     return $this->composer;
 }
开发者ID:opis-colibri,项目名称:core,代码行数:7,代码来源:AbstractScript.php

示例4: run

 /**
  * Runs the project configurator.
  *
  * @return void
  */
 public function run()
 {
     $namespace = $this->ask('Namespace', function ($namespace) {
         return $this->validateNamespace($namespace);
     }, 'App');
     $packageName = $this->ask('Package name', function ($packageName) {
         return $this->validatePackageName($packageName);
     }, $this->suggestPackageName($namespace));
     $license = $this->ask('License', function ($license) {
         return trim($license);
     }, 'proprietary');
     $description = $this->ask('Description', function ($description) {
         return trim($description);
     }, '');
     $file = new JsonFile('./composer.json');
     $config = $file->read();
     $config['name'] = $packageName;
     $config['license'] = $license;
     $config['description'] = $description;
     $config['autoload']['psr-4'] = [$namespace . '\\' => 'src/'];
     $config['autoload-dev']['psr-4'] = [$namespace . '\\Tests\\' => 'tests/'];
     unset($config['scripts']['post-root-package-install']);
     $config['extra']['branch-alias']['dev-master'] = '1.0-dev';
     $file->write($config);
     $this->composer->setPackage(Factory::create($this->io, null, true)->getPackage());
     // reload root package
     $filesystem = new Filesystem();
     $filesystem->removeDirectory('./app/Distribution');
 }
开发者ID:gerryvdm,项目名称:symfony-skeleton,代码行数:34,代码来源:ProjectConfigurator.php

示例5: main

 /**
  * Removes patched packages.
  */
 public function main()
 {
     // Check if all required data is present.
     $this->checkRequirements();
     $composer = Factory::create(new NullIO(), $this->composerJsonPath);
     // Force discarding of changes, these packages are patched after all.
     // @todo Make this configurable with a "force" flag.
     $config = $composer->getConfig();
     $config->merge(['config' => ['discard-changes' => TRUE]]);
     // Get the list of patches.
     $extra = $composer->getPackage()->getExtra();
     if (!empty($extra['patches'])) {
         $repository = $composer->getRepositoryManager()->getLocalRepository();
         $installation_manager = $composer->getInstallationManager();
         // Loop over the patched packages.
         foreach (array_keys($extra['patches']) as $package_name) {
             foreach ($repository->findPackages($package_name) as $package) {
                 // Skip aliases, only remove the actual packages.
                 if (!$package instanceof AliasPackage) {
                     // Remove the package.
                     $this->log("Removing patched package '{$package_name}'.");
                     $operation = new UninstallOperation($package, 'Uninstalling patched package so it can be reinstalled.');
                     $installation_manager->uninstall($repository, $operation);
                 }
             }
         }
         // Re-generate the autoloader to get rid of stale class definitions.
         $generator = $composer->getAutoloadGenerator();
         $localRepo = $composer->getRepositoryManager()->getLocalRepository();
         $package = $composer->getPackage();
         $installationManager = $composer->getInstallationManager();
         $generator->dump($config, $localRepo, $package, $installationManager, 'composer');
     }
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:37,代码来源:RemovePatchedPackagesTask.php

示例6: prepareCommand

 /**
  * {@inheritDoc}
  */
 protected function prepareCommand()
 {
     RuntimeHelper::setupHome($this->file->get(self::SETTING_HOME));
     $command = new UpdateCommand();
     $command->setComposer(Factory::create($this->getIO()));
     return $command;
 }
开发者ID:aschempp,项目名称:tenside-core,代码行数:10,代码来源:UpgradeTask.php

示例7: getComposer

 /**
  * Retrieve a composer instance.
  *
  * @param null|IOInterface $inputOutput The input/output handler to use.
  *
  * @return Composer
  */
 public function getComposer(IOInterface $inputOutput = null)
 {
     if (null === $inputOutput) {
         $inputOutput = $this->getInputOutput();
     }
     RuntimeHelper::setupHome($this->getTensideHome());
     return ComposerFactory::create($inputOutput);
 }
开发者ID:tenside,项目名称:core-bundle,代码行数:15,代码来源:AbstractController.php

示例8: getAvailable

 /**
  * @return PackageInterface[]
  */
 public function getAvailable()
 {
     $plugins = array();
     $composer = Factory::create(new NullIO(), $this->config);
     foreach ($composer->getPackage()->getSuggests() as $id => $version) {
         $plugins[$id] = new Package($id, $version, $version);
     }
     return $plugins;
 }
开发者ID:mathielen,项目名称:package-manager,代码行数:12,代码来源:ComposerSuggestPackageLocatorStrategy.php

示例9: __construct

 /**
  * Constructor
  *
  * @param Filesystem $filesystem
  */
 public function __construct(Filesystem $filesystem)
 {
     $vendor = $filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath('vendor_path.php');
     $vendorPath = $filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath() . (include $vendor);
     // Create Composer
     $io = new \Composer\IO\BufferIO();
     $this->composer = ComposerFactory::create($io, $vendorPath . '/../composer.json');
     $this->locker = $this->composer->getLocker();
 }
开发者ID:kid17,项目名称:magento2,代码行数:14,代码来源:ComposerInformation.php

示例10: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $io = $this->getIO();
     if (!file_exists($file)) {
         $io->writeError('<error>' . $file . ' not found.</error>');
         return 1;
     }
     if (!is_readable($file)) {
         $io->writeError('<error>' . $file . ' is not readable.</error>');
         return 1;
     }
     $validator = new ConfigValidator($io);
     $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
     $checkPublish = !$input->getOption('no-check-publish');
     list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
     $checkLock = !$input->getOption('no-check-lock');
     $lockErrors = array();
     $composer = Factory::create($io, $file);
     $locker = $composer->getLocker();
     if ($locker->isLocked() && !$locker->isFresh()) {
         $lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json.';
     }
     // output errors/warnings
     if (!$errors && !$publishErrors && !$warnings) {
         $io->write('<info>' . $file . ' is valid</info>');
     } elseif (!$errors && !$publishErrors) {
         $io->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
         $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
     } elseif (!$errors) {
         $io->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
         $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
         $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
     } else {
         $io->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
     }
     $messages = array('error' => $errors, 'warning' => $warnings);
     // If checking publish errors, display them as errors, otherwise just show them as warnings
     if ($checkPublish) {
         $messages['error'] = array_merge($messages['error'], $publishErrors);
     } else {
         $messages['warning'] = array_merge($messages['warning'], $publishErrors);
     }
     // If checking lock errors, display them as errors, otherwise just show them as warnings
     if ($checkLock) {
         $messages['error'] = array_merge($messages['error'], $lockErrors);
     } else {
         $messages['warning'] = array_merge($messages['warning'], $lockErrors);
     }
     foreach ($messages as $style => $msgs) {
         foreach ($msgs as $msg) {
             $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
         }
     }
     return $errors || $publishErrors && $checkPublish || $lockErrors && $checkLock ? 1 : 0;
 }
开发者ID:4ung,项目名称:composer,代码行数:62,代码来源:ValidateCommand.php

示例11: __construct

 public function __construct($binDir, $jsonDir)
 {
     \Phar::loadPhar($binDir . '/composer.phar', 'composer.phar');
     require 'phar://composer.phar/src/bootstrap.php';
     $this->io = new \Composer\IO\NullIO();
     $this->composer = \Composer\Factory::create($this->io, $jsonDir . '/composer.json');
     $vendorDir = $this->composer->getConfig()->get('vendor-dir');
     $jsonFile = new \Composer\Json\JsonFile($vendorDir . '/composer/installed.json');
     $this->composer->getRepositoryManager()->setLocalRepository(new \Composer\Repository\InstalledFilesystemRepository($jsonFile));
 }
开发者ID:Xinc-org,项目名称:Xinc.Packager,代码行数:10,代码来源:Outside.php

示例12: createComposer

 /**
  * @param IOInterface $io
  * @param mixed $config
  * @param bool $disablePlugins
  * @return Composer\Composer
  * @throws \Exception|\InvalidArgumentException
  */
 public static function createComposer(IOInterface $io = null, $config = null, $disablePlugins = false)
 {
     try {
         if (null === $io) {
             $io = static::createConsoleIO();
         }
         return Composer\Factory::create($io, $config, $disablePlugins);
     } catch (\InvalidArgumentException $e) {
         throw $e;
     }
 }
开发者ID:modera,项目名称:module,代码行数:18,代码来源:ComposerAdapter.php

示例13: getAvailable

 /**
  * @return CompletePackageInterface[]
  */
 public function getAvailable()
 {
     $composer = Factory::create(new NullIO(), $this->config);
     //transform to complete packages
     $availablePackages = array();
     foreach ($this->packageLocatorStrategy->getAvailable() as $id => $availablePackage) {
         $completePackage = $composer->getRepositoryManager()->findPackage($availablePackage->getName(), $availablePackage->getVersion());
         $availablePackages[$id] = $completePackage;
     }
     return $availablePackages;
 }
开发者ID:mathielen,项目名称:package-manager,代码行数:14,代码来源:RepositoryManager.php

示例14: attachComposerFactory

 /**
  * Attach the composer factory to the command.
  *
  * @param BaseCommand $command The command to patch.
  *
  * @return BaseCommand
  *
  * @throws \InvalidArgumentException When no setComposerFactory method is declared.
  */
 protected function attachComposerFactory(BaseCommand $command)
 {
     if (!method_exists($command, 'setComposerFactory')) {
         throw new \InvalidArgumentException('The passed command does not implement method setComposerFactory()');
     }
     /** @var WrappedCommandTrait $command */
     $command->setComposerFactory(function () {
         return Factory::create($this->getIO());
     });
     return $command;
 }
开发者ID:aschempp,项目名称:tenside-core,代码行数:20,代码来源:AbstractComposerCommandTask.php

示例15: getComposer

 /**
  * @return Composer
  */
 public function getComposer($required = true, $config = null)
 {
     if (null === $this->composer) {
         try {
             $this->composer = Factory::create($this->io, $config);
         } catch (\InvalidArgumentException $e) {
             $this->io->write($e->getMessage());
             exit(1);
         }
     }
     return $this->composer;
 }
开发者ID:ausger,项目名称:satis,代码行数:15,代码来源:Application.php


注:本文中的Composer\Factory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。