本文整理汇总了PHP中Composer\Factory::getComposerFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getComposerFile方法的具体用法?PHP Factory::getComposerFile怎么用?PHP Factory::getComposerFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Factory
的用法示例。
在下文中一共展示了Factory::getComposerFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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';
$removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
$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, $removeKey)) {
foreach ($requirements as $package => $version) {
$baseRequirements[$package] = $version;
if (isset($composer[$removeKey][$package])) {
unset($composer[$removeKey][$package]);
}
}
$composer[$requireKey] = $baseRequirements;
$json->write($composer);
}
$output->writeln('<info>' . $file . ' has been updated</info>');
if ($input->getOption('no-update')) {
return 0;
}
$updateDevMode = !$input->getOption('update-no-dev');
// 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($updateDevMode)->setUpdate(true)->setUpdateWhitelist(array_keys($requirements))->setWhitelistDependencies($input->getOption('update-with-dependencies'));
$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;
}
示例3: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
if (version_compare(PHP_VERSION, '5.3.2', '<')) {
$this->getIO()->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP ' . PHP_VERSION . ', upgrading is strongly recommended.</warning>');
}
if (defined('COMPOSER_DEV_WARNING_TIME')) {
$commandName = '';
if ($name = $this->getCommandName($input)) {
try {
$commandName = $this->find($name)->getName();
} catch (\InvalidArgumentException $e) {
}
}
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
if (time() > COMPOSER_DEV_WARNING_TIME) {
$this->getIO()->writeError(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
}
}
}
if (getenv('COMPOSER_NO_INTERACTION')) {
$input->setInteractive(false);
}
if ($newWorkDir = $this->getNewWorkingDir($input)) {
$oldWorkingDir = getcwd();
chdir($newWorkDir);
if ($this->getIO()->isDebug() >= 4) {
$this->getIO()->writeError('Changed CWD to ' . getcwd());
}
}
$file = Factory::getComposerFile();
if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
if (isset($composer['scripts']) && is_array($composer['scripts'])) {
foreach ($composer['scripts'] as $script => $dummy) {
if (!defined('Composer\\Script\\ScriptEvents::' . str_replace('-', '_', strtoupper($script)))) {
if ($this->has($script)) {
$this->getIO()->writeError('<warning>A script named ' . $script . ' would override a native Composer function and has been skipped</warning>');
} else {
$this->add(new Command\ScriptAliasCommand($script));
}
}
}
}
}
if ($input->hasParameterOption('--profile')) {
$startTime = microtime(true);
$this->io->enableDebugging($startTime);
}
$result = parent::doRun($input, $output);
if (isset($oldWorkingDir)) {
chdir($oldWorkingDir);
}
if (isset($startTime)) {
$this->getIO()->writeError('<info>Memory usage: ' . round(memory_get_usage() / 1024 / 1024, 2) . 'MB (peak: ' . round(memory_get_peak_usage() / 1024 / 1024, 2) . 'MB), time: ' . round(microtime(true) - $startTime, 2) . 's');
}
return $result;
}
示例4: 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;
}
示例5: postAutoloadDump
public function postAutoloadDump(Event $event)
{
// This method is called twice. Run it only once.
if (!$this->runPostAutoloadDump) {
return;
}
$this->runPostAutoloadDump = false;
$config = $this->composer->getConfig();
$suffix = $config->get('autoloader-suffix');
$vendorDir = $config->get('vendor-dir');
$binDir = $config->get('bin-dir');
$autoloadFile = $vendorDir . '/autoload.php';
if (!file_exists($autoloadFile)) {
throw new \RuntimeException(sprintf('Could not adjust autoloader: The file %s was not found.', $autoloadFile));
}
if (!$suffix && !$config->get('autoloader-suffix') && is_readable($autoloadFile)) {
$content = file_get_contents($vendorDir . '/autoload.php');
if (preg_match('{' . self::COMPOSER_AUTOLOADER_BASE . '([^:\\s]+)::}', $content, $match)) {
$suffix = $match[1];
}
}
$contents = file_get_contents($autoloadFile);
$constant = '';
$values = array('AUTOLOAD_CLASS' => var_export(self::COMPOSER_AUTOLOADER_BASE . $suffix, true));
foreach ($values as $key => $value) {
$this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
$constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
$constant .= sprintf(" define('{$this->constantPrefix}{$key}', %s);\n", $value);
$constant .= "}\n\n";
}
$values = array_map(function ($value) {
return var_export($value, true);
}, array('BASE_DIR' => Path::makeRelative(getcwd(), $vendorDir), 'BIN_DIR' => Path::makeRelative($binDir, $vendorDir), 'FILE' => Path::makeRelative(realpath(Factory::getComposerFile()), $vendorDir)));
foreach ($values as $key => $value) {
$this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
$constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
$constant .= sprintf(" define('{$this->constantPrefix}{$key}', realpath(__DIR__ . DIRECTORY_SEPARATOR . %s));\n", $value);
$constant .= "}\n\n";
}
$values = array('VENDOR_DIR' => $vendorDir);
foreach ($values as $key => $value) {
$this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
$constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
$constant .= sprintf(" define('{$this->constantPrefix}{$key}', realpath(__DIR__));\n");
$constant .= "}\n\n";
}
// Regex modifiers:
// "m": \s matches newlines
// "D": $ matches at EOF only
// Translation: insert before the last "return" in the file
$contents = preg_replace('/\\n(?=return [^;]+;\\s*$)/mD', "\n" . $constant, $contents);
file_put_contents($autoloadFile, $contents);
}
示例6: __construct
public function __construct(Composer $composer, IOInterface $io, $type = 'library', Filesystem $filesystem = null)
{
$this->composer = $composer;
$this->config = $composer->getConfig();
$this->io = $io;
$this->root = realpath(dirname(Factory::getComposerFile()));
if (!file_exists($this->root . '/config/modules.php')) {
touch($this->root . '/config/modules.php');
chmod($this->root . '/config/modules.php', 0775);
}
parent::__construct($io, $composer, $type, $filesystem);
}
示例7: 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();
}
}
}
示例8: postCreate
public static function postCreate(Event $event)
{
$fs = new Util\Filesystem();
$file = Factory::getComposerFile();
$json = new Json\JsonFile($file);
$contents = self::unsetJsonNodes($json, static::$jsonNodes);
$contents = self::manipulateJsonContents($contents, static::$jsonContents);
file_put_contents($json->getPath(), $contents);
$projectDir = realpath(".");
self::deleteFiles($fs, $projectDir, self::$deleteFiles);
$installersDir = dirname(realpath(__FILE__));
$fs->remove($installersDir);
}
示例9: setup
public function setup()
{
$this->response = null;
$this->cleanup();
$this->io = $this->prophesize('Composer\\IO\\IOInterface');
$composerDefinition = new ReflectionProperty(OptionalPackages::class, 'composerDefinition');
$composerDefinition->setAccessible(true);
// Get composer.json
$composerFile = Factory::getComposerFile();
$json = new JsonFile($composerFile);
$composerDefinition->setValue($json->read());
$this->projectRoot = realpath(dirname($composerFile));
$config = new ReflectionProperty(OptionalPackages::class, 'config');
$config->setAccessible(true);
$config->setValue(require 'src/ExpressiveInstaller/config.php');
}
示例10: checkComposerSchema
private function checkComposerSchema()
{
$validator = new ConfigValidator($this->getIO());
list($errors, $publishErrors, $warnings) = $validator->validate(Factory::getComposerFile());
if ($errors || $publishErrors || $warnings) {
$messages = array('error' => array_merge($errors, $publishErrors), 'warning' => $warnings);
$output = '';
foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) {
$output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
}
}
return rtrim($output);
}
return true;
}
示例11: initialize
public static function initialize(Event $event)
{
$io = $event->getIO();
$project_dirname = basename(getcwd());
$current_namespace = self::camelize($project_dirname);
$io->write("Initialize {$current_namespace} ...");
$targets = self::globRecursive('app/*.php');
$targets = array_merge($targets, self::globRecursive('app/*.html.twig'));
$targets = array_merge($targets, self::globRecursive('tests/*.php'));
$targets[] = 'composer.json';
$targets[] = 'webroot/index.php';
foreach ($targets as $target) {
$source_text = file_get_contents($target);
$new_source = str_replace(self::PLACEHOLDER, $current_namespace, $source_text);
file_put_contents($target, $new_source);
}
copy('app/config/config_development.php.sample', 'app/config/config_development.php');
chmod('tmp', 0777);
// dumpautoload
$composer = $event->getComposer();
$gen = $composer->getAutoloadGenerator();
$gen->setDevMode(true);
// rename "autoload"
$package = $composer->getPackage();
$autoload = $package->getAutoload();
$autoload['psr-4'][$current_namespace . '\\'] = $autoload['psr-4'][self::PLACEHOLDER . '\\'];
unset($autoload['psr-4'][self::PLACEHOLDER . '\\']);
unset($autoload['psr-4']['DietcubeInstaller\\']);
$package->setAutoload($autoload);
// rewrite json file
$json = new JsonFile(Factory::getComposerFile());
$composer_definition = $json->read();
unset($composer_definition['autoload']['psr-4']['DietcubeInstaller\\']);
unset($composer_definition['scripts']);
$json->write($composer_definition);
$gen->dump($composer->getConfig(), $composer->getRepositoryManager()->getLocalRepository(), $package, $composer->getInstallationManager(), 'composer', false);
$io->write('-------------------------------------------------------------------------');
$io->write('');
$io->write('<comment>Dietcube setup completed.</comment>');
$io->write('');
$io->write('Try now with built-in server:');
$io->write("\$ cd {$project_dirname}");
$io->write('$ DIET_ENV=development php -d variables_order=EGPCS -S 0:8999 -t webroot/');
$io->write('');
$io->write('-------------------------------------------------------------------------');
self::removeMe();
}
示例12: 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;
}
$dialog = $this->getHelperSet()->get('dialog');
$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);
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();
$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));
if (!$install->run()) {
$output->writeln("\n" . '<error>Installation failed, reverting ' . $file . ' to its original content.</error>');
file_put_contents($json->getPath(), $composerBackup);
return 1;
}
return 0;
}
示例13: init
public static function init(Event $event)
{
$io = $event->getIO();
$basePath = realpath(__DIR__ . '/../') . '/';
// Iterate through `$keys` and get the answers
foreach (static::$keys as $key) {
$question = 'What is the ' . str_replace('_', ' ', $key) . '?';
static::$answers[$key] = self::ask($io, $question, 'Larabros');
}
self::recursiveJob($basePath, self::rename());
file_put_contents($basePath . 'composer.json', file_get_contents($basePath . 'composer.json.stub'));
$json = new JsonFile(Factory::getComposerFile());
$composerDefinition = self::getDefinition(static::$answers[':vendor_ns'] . '/' . static::$answers[':package_ns'], $json);
// self::$packageName = [$vendorClass, $packageClass];
// Update composer definition
$json->write($composerDefinition);
$io->write("<info>composer.json is created.\n</info>");
}
示例14: 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';
foreach ($packages as $package) {
if (isset($composer[$type][$package])) {
$json->removeLink($type, $package);
} elseif (isset($composer[$altType][$package])) {
$this->getIO()->writeError('<warning>' . $package . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
$dialog = $this->getHelperSet()->get('dialog');
if ($this->getIO()->isInteractive()) {
if ($dialog->askConfirmation($output, $dialog->getQuestion('Do you want to remove it from ' . $altType, 'yes', '?'), true)) {
$json->removeLink($altType, $package);
}
}
} else {
$this->getIO()->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
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$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');
$install->setVerbose($input->getOption('verbose'))->setDevMode($updateDevMode)->setUpdate(true)->setUpdateWhitelist($packages)->setWhitelistDependencies($input->getOption('update-with-dependencies'))->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));
$status = $install->run();
if ($status !== 0) {
$this->getIO()->writeError("\n" . '<error>Removal failed, reverting ' . $file . ' to its original content.</error>');
file_put_contents($jsonFile->getPath(), $composerBackup);
}
return $status;
}
示例15: getOptions
protected static function getOptions(Event $event)
{
$options = array_merge(array('symfony-app-dir' => 'app', 'symfony-web-dir' => 'web'), $event->getComposer()->getPackage()->getExtra());
$options['symfony-assets-install'] = getenv('SYMFONY_ASSETS_INSTALL') ?: @$options['symfony-assets-install'];
if (!$options['symfony-assets-install']) {
$options['symfony-assets-install'] = 'symlink';
}
$options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout');
$options['vendor-dir'] = $event->getComposer()->getConfig()->get('vendor-dir');
$composerJsonFile = realpath(\Composer\Factory::getComposerFile());
$rootDir = dirname($composerJsonFile);
$options['root-dir'] = $rootDir;
$options['app-dir-full'] = $rootDir . DIRECTORY_SEPARATOR . $options['symfony-app-dir'];
$options['web-dir-full'] = $rootDir . DIRECTORY_SEPARATOR . $options['symfony-web-dir'];
if ('/' == substr($options['vendor-dir'], 0, 1) || ':' == substr($options['vendor-dir'], 1, 1)) {
$options['vendor-dir-full'] = $options['vendor-dir'];
} else {
$options['vendor-dir-full'] = $rootDir . DIRECTORY_SEPARATOR . $options['vendor-dir'];
}
return $options;
}