本文整理汇总了PHP中Composer\Installer类的典型用法代码示例。如果您正苦于以下问题:PHP Installer类的具体用法?PHP Installer怎么用?PHP Installer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Installer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
if ($input->post('FORM_SUBMIT') == 'tl_composer_migrate_undo') {
/** @var RootPackage $rootPackage */
$rootPackage = $this->composer->getPackage();
$requires = $rootPackage->getRequires();
foreach (array_keys($requires) as $package) {
if ($package != 'contao-community-alliance/composer') {
unset($requires[$package]);
}
}
$rootPackage->setRequires($requires);
$lockPathname = preg_replace('#\\.json$#', '.lock', $this->configPathname);
/** @var DownloadManager $downloadManager */
$downloadManager = $this->composer->getDownloadManager();
$downloadManager->setOutputProgress(false);
$installer = Installer::create($this->io, $this->composer);
if (file_exists(TL_ROOT . '/' . $lockPathname)) {
$installer->setUpdate(true);
}
if ($installer->run()) {
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
} else {
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
$this->redirect('contao/main.php?do=composer&migrate=undo');
}
// load config
$json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
$config = $json->read();
// remove migration status
unset($config['extra']['contao']['migrated']);
// write config
$json->write($config);
// disable composer client and enable repository client
$inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
$inactiveModules[] = '!composer';
foreach (array('rep_base', 'rep_client', 'repository') as $module) {
$pos = array_search($module, $inactiveModules);
if ($pos !== false) {
unset($inactiveModules[$pos]);
}
}
if (version_compare(VERSION, '3', '>=')) {
$skipFile = new \File('system/modules/!composer/.skip');
$skipFile->write('Remove this file to enable the module');
$skipFile->close();
}
if (file_exists(TL_ROOT . '/system/modules/repository/.skip')) {
$skipFile = new \File('system/modules/repository/.skip');
$skipFile->delete();
}
$this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
$this->redirect('contao/main.php?do=repository_manager');
}
$template = new \BackendTemplate('be_composer_client_migrate_undo');
$template->composer = $this->composer;
$template->output = $_SESSION['COMPOSER_OUTPUT'];
unset($_SESSION['COMPOSER_OUTPUT']);
return $template->parse();
}
开发者ID:designs2,项目名称:composer-client,代码行数:63,代码来源:UndoMigrationController.php
示例2: 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
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$factory = new Factory();
$file = $factory->getComposerFile();
if (!file_exists($file)) {
$output->writeln('<error>' . $file . ' not found.</error>');
return 1;
}
if (!is_readable($file)) {
$output->writeln('<error>' . $file . ' is not readable.</error>');
return 1;
}
$dialog = $this->getHelperSet()->get('dialog');
$json = new JsonFile($file);
$composer = $json->read();
$requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'));
$requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
$baseRequirements = array_key_exists($requireKey, $composer) ? $composer[$requireKey] : array();
$requirements = $this->formatRequirements($requirements);
if (!$this->updateFileCleanly($json, $baseRequirements, $requirements, $requireKey)) {
foreach ($requirements as $package => $version) {
$baseRequirements[$package] = $version;
}
$composer[$requireKey] = $baseRequirements;
$json->write($composer);
}
$output->writeln('<info>' . $file . ' has been updated</info>');
// Update packages
$composer = $this->getComposer();
$io = $this->getIO();
$install = Installer::create($io, $composer);
$install->setVerbose($input->getOption('verbose'))->setPreferSource($input->getOption('prefer-source'))->setDevMode($input->getOption('dev'))->setUpdate(true)->setUpdateWhitelist($requirements);
return $install->run() ? 0 : 1;
}
开发者ID:nicodmf,项目名称:composer,代码行数:34,代码来源:RequireCommand.php
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($preferSource)->setPreferDist($preferDist)->setDevMode($input->getOption('dev'))->setRunScripts(!$input->getOption('no-scripts'))->setOptimizeAutoloader($input->getOption('optimize-autoloader'));
if ($input->getOption('no-custom-installers')) {
$install->disableCustomInstallers();
}
return $install->run() ? 0 : 1;
}
开发者ID:robywan,项目名称:composer,代码行数:30,代码来源:InstallCommand.php
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('no-custom-installers')) {
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
$input->setOption('no-plugins', true);
}
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($preferSource)->setPreferDist($preferDist)->setDevMode(!$input->getOption('no-dev'))->setRunScripts(!$input->getOption('no-scripts'))->setOptimizeAutoloader($input->getOption('optimize-autoloader'));
if ($input->getOption('no-plugins')) {
$install->disablePlugins();
}
return $install->run();
}
开发者ID:jemilabdeljelil,项目名称:insurance-2,代码行数:35,代码来源:InstallCommand.php
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO();
if ($args = $input->getArgument('packages')) {
$io->writeError('<error>Invalid argument ' . implode(' ', $args) . '. Use "composer require ' . implode(' ', $args) . '" instead to add packages to your composer.json.</error>');
return 1;
}
if ($input->getOption('no-custom-installers')) {
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
$input->setOption('no-plugins', true);
}
if ($input->getOption('dev')) {
$io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
}
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$install = Installer::create($io, $composer);
$config = $composer->getConfig();
list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
$optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
$authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($preferSource)->setPreferDist($preferDist)->setDevMode(!$input->getOption('no-dev'))->setDumpAutoloader(!$input->getOption('no-autoloader'))->setRunScripts(!$input->getOption('no-scripts'))->setSkipSuggest($input->getOption('no-suggest'))->setOptimizeAutoloader($optimize)->setClassMapAuthoritative($authoritative)->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));
if ($input->getOption('no-plugins')) {
$install->disablePlugins();
}
return $install->run();
}
开发者ID:Rudloff,项目名称:composer,代码行数:29,代码来源:InstallCommand.php
示例7: execute
/**
* Remove packages from the root install.
*
* @param $packages array Indexed array of package names to remove
*
* @throws \Bolt\Exception\PackageManagerException
*
* @return int 0 on success or a positive error code on failure
*/
public function execute(array $packages)
{
if (empty($packages)) {
throw new PackageManagerException('No package specified for removal');
}
$io = $this->app['extend.manager']->getIO();
$options = $this->app['extend.manager']->getOptions();
$jsonFile = new JsonFile($options['composerjson']);
$composerDefinition = $jsonFile->read();
$composerBackup = file_get_contents($jsonFile->getPath());
$json = new JsonConfigSource($jsonFile);
$type = $options['dev'] ? 'require-dev' : 'require';
// Remove packages from JSON
foreach ($packages as $package) {
if (isset($composerDefinition[$type][$package])) {
$json->removeLink($type, $package);
}
}
// Reload Composer config
$composer = $this->app['extend.manager']->getFactory()->resetComposer();
$install = Installer::create($io, $composer);
try {
$install->setVerbose($options['verbose'])->setDevMode(!$options['updatenodev'])->setUpdate(true)->setUpdateWhitelist($packages)->setWhitelistDependencies($options['updatewithdependencies'])->setIgnorePlatformRequirements($options['ignoreplatformreqs']);
$status = $install->run();
if ($status !== 0) {
// Write out old JSON file
file_put_contents($jsonFile->getPath(), $composerBackup);
}
} catch (\Exception $e) {
$msg = __CLASS__ . '::' . __FUNCTION__ . ' recieved an error from Composer: ' . $e->getMessage() . ' in ' . $e->getFile() . '::' . $e->getLine();
$this->app['logger.system']->critical($msg, array('event' => 'exception', 'exception' => $e));
throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
}
return $status;
}
开发者ID:aleksabp,项目名称:bolt,代码行数:44,代码来源:RemovePackage.php
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$io = $this->getApplication()->getIO();
$install = Installer::create($io, $composer);
return $install->run((bool) $input->getOption('prefer-source'), (bool) $input->getOption('dry-run'), (bool) $input->getOption('verbose'), (bool) $input->getOption('no-install-recommends'), (bool) $input->getOption('install-suggests'));
}
开发者ID:robo47,项目名称:composer,代码行数:7,代码来源:InstallCommand.php
示例9: execute
/**
* Update packages.
*
* @param $packages array Indexed array of package names to update
* @param $options array [Optional] changed option set
*
* @throws \Bolt\Exception\PackageManagerException
*
* @return int 0 on success or a positive error code on failure
*/
public function execute(array $packages = [], array $options = [])
{
/** @var $composer \Composer\Composer */
$composer = $this->getComposer();
$io = $this->getIO();
$packageManagerOptions = $this->app['extend.action.options'];
// Handle passed in options
if (!empty($options)) {
$options = Arr::mergeRecursiveDistinct($packageManagerOptions, $options);
} else {
$options = $packageManagerOptions;
}
$install = Installer::create($io, $composer);
$config = $composer->getConfig();
$optimize = $config->get('optimize-autoloader');
// Set preferred install method
$prefer = $this->getPreferedTarget($config->get('preferred-install'));
try {
$install->setDryRun($options['dryrun'])->setVerbose($options['verbose'])->setPreferSource($prefer['source'])->setPreferDist($prefer['dist'])->setDevMode(!$options['nodev'])->setDumpAutoloader(!$options['noautoloader'])->setRunScripts(!$options['noscripts'])->setOptimizeAutoloader($optimize)->setUpdate(true)->setUpdateWhitelist($packages)->setWhitelistDependencies($options['withdependencies'])->setIgnorePlatformRequirements($options['ignoreplatformreqs'])->setPreferStable($options['preferstable'])->setPreferLowest($options['preferlowest'])->disablePlugins();
return $install->run();
} catch (\Exception $e) {
$msg = __CLASS__ . '::' . __FUNCTION__ . ' recieved an error from Composer: ' . $e->getMessage() . ' in ' . $e->getFile() . '::' . $e->getLine();
$this->app['logger.system']->critical($msg, ['event' => 'exception', 'exception' => $e]);
throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
}
}
开发者ID:atiarda,项目名称:bolt,代码行数:36,代码来源:UpdatePackage.php
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$io = $this->getIO();
$install = Installer::create($io, $composer);
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($input->getOption('prefer-source'))->setDevMode($input->getOption('dev'))->setRunScripts(!$input->getOption('no-scripts'));
return $install->run() ? 0 : 1;
}
开发者ID:nicodmf,项目名称:composer,代码行数:8,代码来源:InstallCommand.php
示例11: execute
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$io = new ConsoleIO($input, $output, $this->getHelperSet());
$factory = new ComposerFactory($io);
$composer = $factory->createComposer();
$installer = Installer::create($io, $composer);
$installer->run();
}
开发者ID:eva,项目名称:eva,代码行数:11,代码来源:ComposerCommand.php
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO();
if ($input->getOption('no-custom-installers')) {
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
$input->setOption('no-plugins', true);
}
if ($input->getOption('dev')) {
$io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
}
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
$packages = $input->getArgument('packages');
if ($input->getOption('interactive')) {
$packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
}
if ($input->getOption('root-reqs')) {
$require = array_keys($composer->getPackage()->getRequires());
if (!$input->getOption('no-dev')) {
$requireDev = array_keys($composer->getPackage()->getDevRequires());
$require = array_merge($require, $requireDev);
}
if (!empty($packages)) {
$packages = array_intersect($packages, $require);
} else {
$packages = $require;
}
}
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
$config = $composer->getConfig();
switch ($config->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
$authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($preferSource)->setPreferDist($preferDist)->setDevMode(!$input->getOption('no-dev'))->setDumpAutoloader(!$input->getOption('no-autoloader'))->setRunScripts(!$input->getOption('no-scripts'))->setOptimizeAutoloader($optimize)->setClassMapAuthoritative($authoritative)->setUpdate(true)->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $packages)->setWhitelistDependencies($input->getOption('with-dependencies'))->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))->setPreferStable($input->getOption('prefer-stable'))->setPreferLowest($input->getOption('prefer-lowest'));
if ($input->getOption('no-plugins')) {
$install->disablePlugins();
}
return $install->run();
}
开发者ID:dazzle-libraries,项目名称:composer,代码行数:58,代码来源:UpdateCommand.php
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$packages = $input->getArgument('packages');
$file = Factory::getComposerFile();
$jsonFile = new JsonFile($file);
$composer = $jsonFile->read();
$composerBackup = file_get_contents($jsonFile->getPath());
$json = new JsonConfigSource($jsonFile);
$type = $input->getOption('dev') ? 'require-dev' : 'require';
$altType = !$input->getOption('dev') ? 'require-dev' : 'require';
$io = $this->getIO();
if ($input->getOption('update-with-dependencies')) {
$io->writeError('<warning>You are using the deprecated option "update-with-dependencies". This is now default behaviour. The --no-update-with-dependencies option can be used to remove a package without its dependencies.</warning>');
}
foreach ($packages as $package) {
if (isset($composer[$type][$package])) {
$json->removeLink($type, $package);
} elseif (isset($composer[$altType][$package])) {
$io->writeError('<warning>' . $package . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
if ($io->isInteractive()) {
if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ', true)) {
$json->removeLink($altType, $package);
}
}
} else {
$io->writeError('<warning>' . $package . ' is not required in your composer.json and has not been removed</warning>');
}
}
if ($input->getOption('no-update')) {
return 0;
}
// Update packages
$this->resetComposer();
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$install = Installer::create($io, $composer);
$updateDevMode = !$input->getOption('update-no-dev');
$optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
$authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
$install->setVerbose($input->getOption('verbose'))->setDevMode($updateDevMode)->setOptimizeAutoloader($optimize)->setClassMapAuthoritative($authoritative)->setUpdate(true)->setUpdateWhitelist($packages)->setWhitelistDependencies(!$input->getOption('no-update-with-dependencies'))->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));
$exception = null;
try {
$status = $install->run();
} catch (\Exception $exception) {
$status = 1;
}
if ($status !== 0) {
$io->writeError("\n" . '<error>Removal failed, reverting ' . $file . ' to its original content.</error>');
file_put_contents($jsonFile->getPath(), $composerBackup);
}
if ($exception) {
throw $exception;
}
return $status;
}
开发者ID:dazzle-libraries,项目名称:composer,代码行数:57,代码来源:RemoveCommand.php
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$io = $this->getIO();
$install = Installer::create($io, $composer);
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($input->getOption('prefer-source'))->setDevMode($input->getOption('dev'))->setRunScripts(!$input->getOption('no-scripts'))->setUpdate(true)->setUpdateWhitelist($input->getArgument('packages'));
if ($input->getOption('no-custom-installers')) {
$install->disableCustomInstallers();
}
return $install->run() ? 0 : 1;
}
开发者ID:rufinus,项目名称:composer,代码行数:11,代码来源:UpdateCommand.php
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$io = $this->getIO();
$install = Installer::create($io, $composer);
$install->setDryRun($input->getOption('dry-run'))->setVerbose($input->getOption('verbose'))->setPreferSource($input->getOption('prefer-source'))->setPreferDist($input->getOption('prefer-dist'))->setDevMode($input->getOption('dev'))->setRunScripts(!$input->getOption('no-scripts'))->setOptimizeAutoloader($input->getOption('optimize-autoloader'));
if ($input->getOption('no-custom-installers')) {
$install->disableCustomInstallers();
}
return $install->run() ? 0 : 1;
}
开发者ID:nickelc,项目名称:composer,代码行数:11,代码来源:InstallCommand.php
示例16: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$file = Factory::getComposerFile();
if (!file_exists($file) && !file_put_contents($file, "{\n}\n")) {
$output->writeln('<error>' . $file . ' could not be created.</error>');
return 1;
}
if (!is_readable($file)) {
$output->writeln('<error>' . $file . ' is not readable.</error>');
return 1;
}
if (!is_writable($file)) {
$output->writeln('<error>' . $file . ' is not writable.</error>');
return 1;
}
$json = new JsonFile($file);
$composer = $json->read();
$composerBackup = file_get_contents($json->getPath());
$requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'));
$requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
$baseRequirements = array_key_exists($requireKey, $composer) ? $composer[$requireKey] : array();
$requirements = $this->formatRequirements($requirements);
// validate requirements format
$versionParser = new VersionParser();
foreach ($requirements as $constraint) {
$versionParser->parseConstraints($constraint);
}
if (!$this->updateFileCleanly($json, $baseRequirements, $requirements, $requireKey)) {
foreach ($requirements as $package => $version) {
$baseRequirements[$package] = $version;
}
$composer[$requireKey] = $baseRequirements;
$json->write($composer);
}
$output->writeln('<info>' . $file . ' has been updated</info>');
if ($input->getOption('no-update')) {
return 0;
}
// Update packages
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$install = Installer::create($io, $composer);
$install->setVerbose($input->getOption('verbose'))->setPreferSource($input->getOption('prefer-source'))->setPreferDist($input->getOption('prefer-dist'))->setDevMode(true)->setUpdate(true)->setUpdateWhitelist(array_keys($requirements));
$status = $install->run();
if ($status !== 0) {
$output->writeln("\n" . '<error>Installation failed, reverting ' . $file . ' to its original content.</error>');
file_put_contents($json->getPath(), $composerBackup);
}
return $status;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:53,代码来源:RequireCommand.php
示例17: execute
/**
* Require (install) a package.
*
* @param array $package Package names and version to require
* - Format: ['name' => '', 'version' => '']
*
* @throws \Bolt\Exception\PackageManagerException
*
* @return int 0 on success or a positive error code on failure
*/
public function execute(array $package)
{
$this->getComposer();
$io = $this->getIO();
/** @var \Bolt\Filesystem\Handler\JsonFile $jsonFile */
$jsonFile = $this->getOptions()->composerJson();
$newlyCreated = !$jsonFile->exists();
if ($newlyCreated) {
$this->app['extend.manager.json']->update();
}
// Format the package array
$package = $this->formatRequirements($package);
// Validate requirements format
$versionParser = new VersionParser();
foreach ($package as $constraint) {
$versionParser->parseConstraints($constraint);
}
// Get a back up of the file contents
$composerBackup = $jsonFile->parse();
// Update our JSON file now with a specific version.
// This is what Composer will read, and use, internally during the process.
// After that is complete, we'll re-save with a constraint
$this->updateComposerJson($jsonFile, $package, false);
// JSON file has been created/updated, if we're not installing, exit
if ($this->getOptions()->noUpdate()) {
return 0;
}
// Reload Composer config
$composer = $this->resetComposer();
/** @var $install \Composer\Installer */
$install = Installer::create($io, $composer)->setVerbose($this->getOptions()->verbose())->setPreferSource($this->getOptions()->preferSource())->setPreferDist($this->getOptions()->preferDist())->setDevMode(!$this->getOptions()->updateNoDev())->setOptimizeAutoloader($this->getOptions()->optimizeAutoloader())->setClassMapAuthoritative($this->getOptions()->classmapAuthoritative())->setUpdate($this->getOptions()->update())->setUpdateWhitelist(array_keys($package))->setWhitelistDependencies($this->getOptions()->updateWithDependencies())->setIgnorePlatformRequirements($this->getOptions()->ignorePlatformReqs())->setRunScripts(!$this->getOptions()->noScripts());
try {
$status = $install->run();
if ($status !== 0) {
if ($newlyCreated) {
// Installation failed, deleting JSON
$jsonFile->delete();
} else {
// Installation failed, reverting JSON to its original content
$jsonFile->dump($composerBackup);
}
}
// Update our JSON file now with a constraint
$this->updateComposerJson($jsonFile, $package, true);
return $status;
} catch (\Exception $e) {
// Installation failed, reverting JSON to its original content
$jsonFile->dump($composerBackup);
$msg = sprintf('%s recieved an error from Composer: %s in %s::%s', __METHOD__, $e->getMessage(), $e->getFile(), $e->getLine());
$this->app['logger.system']->critical($msg, ['event' => 'exception', 'exception' => $e]);
throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
}
}
开发者ID:bolt,项目名称:bolt,代码行数:63,代码来源:RequirePackage.php
示例18: perform
public function perform($configs)
{
if (is_file(".ethna")) {
return;
}
$config = array_merge(array("project" => "example", "renderer" => "smarty"), $configs);
$config = $this->processParams($config, $config);
$targets = array("app/action/Index.php", "app/view/Index.php", "app/Example_ActionClass.php", "app/Example_ActionForm.php", "app/Example_Controller.php", "app/Example_Error.php", "app/Example_ViewClass.php", "etc/example-ini.php", "skel/skel.action.php", "skel/skel.action_cli.php", "skel/skel.app_object.php", "skel/skel.entry_cli.php", "skel/skel.entry_www.php", "skel/skel.template.tpl", "skel/skel.view.php", "www/index.php");
$project_class = self::camerize($config['project']);
if ($config['renderer'] == 'twig') {
if (file_exists("app/Example_Controller.php")) {
$data = file_get_contents("app/Example_Controller.php");
$data = preg_replace("/Ethna_Renderer_Smarty/", "Ethna_Renderer_Twig", $data);
file_put_contents("app/Example_Controller.php", $data);
}
}
foreach ($targets as $target) {
if (file_exists($target)) {
$data = file_get_contents($target);
$data = preg_replace("/Example/", $project_class, $data);
$data = preg_replace("/EXAMPLE/", strtoupper($project_class), $data);
file_put_contents($target, $data);
$name = basename($target);
if (preg_match("/Example/", $name)) {
$name = preg_replace("/Example/", $project_class, $name);
$dir = dirname($target);
rename($target, $dir . DIRECTORY_SEPARATOR . $name);
} else {
if (preg_match("/example-ini.php/", $name)) {
$dir = dirname($target);
$name = preg_replace("/example/", $config['project'], $name);
rename($target, $dir . DIRECTORY_SEPARATOR . $name);
}
}
}
}
file_put_contents(".ethna", sprintf("[project]\ncontroller_file = '%s'\ncontroller_class = '%s'", "app/{$project_class}_Controller.php", "{$project_class}_Controller"));
if ($config['renderer'] == 'twig') {
$file = Factory::getComposerFile();
$prior_json = $composer_json = json_decode(file_get_contents($file), true);
if (!isset($composer_json['require']['twig/twig'])) {
$composer_json['require']['twig/twig'] = '1.*';
file_put_contents($file, json_encode($composer_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
$composer = $this->composer = Factory::create($this->io, null, true);
$composer->getDownloadManager()->setOutputProgress(true);
$install = Installer::create($this->io, $composer);
$install->setVerbose(true)->setPreferSource(true)->setPreferDist(false)->setDevMode(true)->setUpdate(true)->setUpdateWhitelist(array_keys($prior_json['require']));
// とりあえず
$status = $install->run();
}
}
}
开发者ID:ethna,项目名称:ethna-composer-handler,代码行数:52,代码来源:Processor.php
示例19: execute
/**
* Install packages.
*
* @throws \Bolt\Exception\PackageManagerException
*
* @return int 0 on success or a positive error code on failure
*/
public function execute()
{
/** @var $composer \Composer\Composer */
$composer = $this->getComposer();
$io = $this->getIO();
$config = $composer->getConfig();
$optimize = $this->getOptions()->optimizeAutoloader() || $config->get('optimize-autoloader');
$authoritative = $this->getOptions()->classmapAuthoritative() || $config->get('classmap-authoritative');
$install = Installer::create($io, $composer)->setDryRun($this->getOptions()->dryRun())->setVerbose($this->getOptions()->verbose())->setPreferSource($this->getOptions()->preferSource())->setPreferDist($this->getOptions()->preferDist())->setDevMode(!$this->getOptions()->noDev())->setDumpAutoloader(!$this->getOptions()->noAutoloader())->setRunScripts(!$this->getOptions()->noScripts())->setOptimizeAutoloader($optimize)->setClassMapAuthoritative($authoritative)->setIgnorePlatformRequirements($this->getOptions()->ignorePlatformReqs());
try {
return $install->run();
} catch (\Exception $e) {
$msg = sprintf('%s recieved an error from Composer: %s in %s::%s', __METHOD__, $e->getMessage(), $e->getFile(), $e->getLine());
$this->app['logger.system']->critical($msg, ['event' => 'exception', 'exception' => $e]);
throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
}
}
开发者ID:d-m-,项目名称:bolt,代码行数:24,代码来源:InstallPackage.php
|
请发表评论