本文整理汇总了PHP中Composer\Package\Version\VersionParser::formatVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP VersionParser::formatVersion方法的具体用法?PHP VersionParser::formatVersion怎么用?PHP VersionParser::formatVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\Version\VersionParser
的用法示例。
在下文中一共展示了VersionParser::formatVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOutput
/**
* {@inheritdoc}
*/
public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
{
if (!$operation instanceof UpdateOperation) {
throw new \LogicException('Operation should be an instance of UpdateOperation');
}
$output = [];
$initialPackage = $operation->getInitialPackage();
$targetPackage = $operation->getTargetPackage();
$versionFrom = new Version($initialPackage->getVersion(), $initialPackage->getPrettyVersion(), method_exists($initialPackage, 'getFullPrettyVersion') ? $initialPackage->getFullPrettyVersion() : VersionParser::formatVersion($initialPackage));
$versionTo = new Version($targetPackage->getVersion(), $targetPackage->getPrettyVersion(), method_exists($targetPackage, 'getFullPrettyVersion') ? $targetPackage->getFullPrettyVersion() : VersionParser::formatVersion($targetPackage));
$action = 'updated';
if (Comparator::greaterThan($versionFrom->getName(), $versionTo->getName())) {
$action = 'downgraded';
}
$output[] = sprintf(' - <fg=green>%s</fg=green> %s from <fg=yellow>%s</fg=yellow> to <fg=yellow>%s</fg=yellow>', $initialPackage->getName(), $action, $versionFrom->getPretty(), $versionTo->getPretty());
if ($urlGenerator) {
$compareUrl = $urlGenerator->generateCompareUrl($initialPackage->getSourceUrl(), $versionFrom, $targetPackage->getSourceUrl(), $versionTo);
if (!empty($compareUrl)) {
$output[] = sprintf(' See changes: %s', $compareUrl);
}
$releaseUrl = $urlGenerator->generateReleaseUrl($this->extractSourceUrl($operation), $versionTo);
if (!empty($releaseUrl)) {
$output[] = sprintf(' Release notes: %s', $releaseUrl);
}
}
return $output;
}
示例2: update
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
if (!$target->getSourceReference()) {
throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
}
$name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
if ($target->getSourceType() === 'svn') {
$from = $initial->getSourceReference();
$to = $target->getSourceReference();
} else {
$from = substr($initial->getSourceReference(), 0, 7);
$to = substr($target->getSourceReference(), 0, 7);
}
$name .= ' ' . $initial->getPrettyVersion();
} else {
$from = VersionParser::formatVersion($initial);
$to = VersionParser::formatVersion($target);
}
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$this->cleanChanges($initial, $path, true);
$urls = $target->getSourceUrls();
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doUpdate($initial, $target, $path, $url);
break;
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
} else {
$this->reapplyChanges($path);
throw $e;
}
}
}
$this->reapplyChanges($path);
if ($this->io->isVerbose()) {
$message = 'Pulling in changes:';
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
if (!trim($logs)) {
$message = 'Rolling back changes:';
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
}
if (trim($logs)) {
$logs = implode("\n", array_map(function ($line) {
return ' ' . $line;
}, explode("\n", $logs)));
$this->io->writeError(' ' . $message);
$this->io->writeError($logs);
}
}
$this->io->writeError('');
}
示例3: getOutput
/**
* {@inheritdoc}
*/
public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
{
if (!$operation instanceof UninstallOperation) {
throw new \LogicException('Operation should be an instance of UninstallOperation');
}
$output = [];
$package = $operation->getPackage();
$version = new Version($package->getVersion(), $package->getPrettyVersion(), method_exists($package, 'getFullPrettyVersion') ? $package->getFullPrettyVersion() : VersionParser::formatVersion($package));
$output[] = sprintf(' - <fg=green>%s</fg=green> removed (installed version was <fg=yellow>%s</fg=yellow>)', $package->getName(), $version->getPretty());
return $output;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$root = $composer->getPackage();
$repo = $composer->getRepositoryManager()->getLocalRepository();
$versionParser = new VersionParser();
if ($input->getOption('no-dev')) {
$packages = $this->filterRequiredPackages($repo, $root);
} else {
$packages = $this->appendPackages($repo->getPackages(), array());
}
ksort($packages);
switch ($format = $input->getOption('format')) {
case 'text':
$this->getIO()->write('Name: <comment>' . $root->getPrettyName() . '</comment>');
$this->getIO()->write('Version: <comment>' . $versionParser->formatVersion($root) . '</comment>');
$this->getIO()->write('Licenses: <comment>' . (implode(', ', $root->getLicense()) ?: 'none') . '</comment>');
$this->getIO()->write('Dependencies:');
$this->getIO()->write('');
$table = new Table($output);
$table->setStyle('compact');
$table->getStyle()->setVerticalBorderChar('');
$table->getStyle()->setCellRowContentFormat('%s ');
$table->setHeaders(array('Name', 'Version', 'License'));
foreach ($packages as $package) {
$table->addRow(array($package->getPrettyName(), $versionParser->formatVersion($package), implode(', ', $package->getLicense()) ?: 'none'));
}
$table->render();
break;
case 'json':
foreach ($packages as $package) {
$dependencies[$package->getPrettyName()] = array('version' => $versionParser->formatVersion($package), 'license' => $package->getLicense());
}
$this->getIO()->write(JsonFile::encode(array('name' => $root->getPrettyName(), 'version' => $versionParser->formatVersion($root), 'license' => $root->getLicense(), 'dependencies' => $dependencies)));
break;
default:
throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
}
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$root = $composer->getPackage();
$repo = $composer->getRepositoryManager()->getLocalRepository();
$versionParser = new VersionParser();
$packages = array();
foreach ($repo->getPackages() as $package) {
$packages[$package->getName()] = $package;
}
ksort($packages);
switch ($format = $input->getOption('format')) {
case 'text':
$output->writeln('Name: <comment>' . $root->getPrettyName() . '</comment>');
$output->writeln('Version: <comment>' . $versionParser->formatVersion($root) . '</comment>');
$output->writeln('Licenses: <comment>' . (implode(', ', $root->getLicense()) ?: 'none') . '</comment>');
$output->writeln('Dependencies:');
$table = $this->getHelperSet()->get('table');
$table->setLayout(TableHelper::LAYOUT_BORDERLESS);
$table->setHorizontalBorderChar('');
foreach ($packages as $package) {
$table->addRow(array($package->getPrettyName(), $versionParser->formatVersion($package), implode(', ', $package->getLicense()) ?: 'none'));
}
$table->render($output);
break;
case 'json':
foreach ($packages as $package) {
$dependencies[$package->getPrettyName()] = array('version' => $versionParser->formatVersion($package), 'license' => $package->getLicense());
}
$output->writeln(JsonFile::encode(array('name' => $root->getPrettyName(), 'version' => $versionParser->formatVersion($root), 'license' => $root->getLicense(), 'dependencies' => $dependencies)));
break;
default:
throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
}
}
示例6: update
/**
* {@inheritDoc}
*/
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
if (!$target->getSourceReference()) {
throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
}
$name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
if ($target->getSourceType() === 'svn') {
$from = $initial->getSourceReference();
$to = $target->getSourceReference();
} else {
$from = substr($initial->getSourceReference(), 0, 7);
$to = substr($target->getSourceReference(), 0, 7);
}
$name .= ' ' . $initial->getPrettyVersion();
} else {
$from = VersionParser::formatVersion($initial);
$to = VersionParser::formatVersion($target);
}
$this->io->write(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$this->cleanChanges($path, true);
try {
$this->doUpdate($initial, $target, $path);
} catch (\Exception $e) {
// in case of failed update, try to reapply the changes before aborting
$this->reapplyChanges($path);
throw $e;
}
$this->reapplyChanges($path);
//print the commit logs if in verbose mode
if ($this->io->isVerbose()) {
$message = 'Pulling in changes:';
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
if (!trim($logs)) {
$message = 'Rolling back changes:';
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
}
if (trim($logs)) {
$logs = implode("\n", array_map(function ($line) {
return ' ' . $line;
}, explode("\n", $logs)));
$this->io->write(' ' . $message);
$this->io->write($logs);
}
}
$this->io->write('');
}
示例7: getOutput
/**
* {@inheritdoc}
*/
public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
{
if (!$operation instanceof InstallOperation) {
throw new \LogicException('Operation should be an instance of InstallOperation');
}
$output = [];
$package = $operation->getPackage();
$version = new Version($package->getVersion(), $package->getPrettyVersion(), method_exists($package, 'getFullPrettyVersion') ? $package->getFullPrettyVersion() : VersionParser::formatVersion($package));
$output[] = sprintf(' - <fg=green>%s</fg=green> installed in version <fg=yellow>%s</fg=yellow>', $package->getName(), $version->getPretty());
if ($urlGenerator) {
$releaseUrl = $urlGenerator->generateReleaseUrl($this->extractSourceUrl($operation), $version);
if (!empty($releaseUrl)) {
$output[] = sprintf(' Release notes: %s', $releaseUrl);
}
}
return $output;
}
示例8: testFormatVersionForDevPackage
/**
* @dataProvider formattedVersions
*/
public function testFormatVersionForDevPackage(PackageInterface $package, $truncate, $expected)
{
$this->assertSame($expected, VersionParser::formatVersion($package, $truncate));
}
示例9: installRootPackage
protected function installRootPackage(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false)
{
if (null === $repositoryUrl) {
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION) && file_exists($repositoryUrl)) {
$json = new JsonFile($repositoryUrl, new RemoteFilesystem($io, $config));
$data = $json->read();
if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
$sourceRepo = new ComposerRepository(array('url' => 'file://' . strtr(realpath($repositoryUrl), '\\', '/')), $io, $config);
} else {
$sourceRepo = new FilesystemRepository($json);
}
} elseif (0 === strpos($repositoryUrl, 'http')) {
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
} else {
throw new \InvalidArgumentException("Invalid repository url given. Has to be a .json file or an http url.");
}
$parser = new VersionParser();
$requirements = $parser->parseNameVersionPairs(array($packageName));
$name = strtolower($requirements[0]['name']);
if (!$packageVersion && isset($requirements[0]['version'])) {
$packageVersion = $requirements[0]['version'];
}
if (null === $stability) {
if (preg_match('{^[^,\\s]*?@(' . implode('|', array_keys(BasePackage::$stabilities)) . ')$}i', $packageVersion, $match)) {
$stability = $match[1];
} else {
$stability = VersionParser::parseStability($packageVersion);
}
}
$stability = VersionParser::normalizeStability($stability);
if (!isset(BasePackage::$stabilities[$stability])) {
throw new \InvalidArgumentException('Invalid stability provided (' . $stability . '), must be one of: ' . implode(', ', array_keys(BasePackage::$stabilities)));
}
$pool = new Pool($stability);
$pool->addRepository($sourceRepo);
// find the latest version if there are multiple
$versionSelector = new VersionSelector($pool);
$package = $versionSelector->findBestCandidate($name, $packageVersion);
if (!$package) {
throw new \InvalidArgumentException("Could not find package {$name}" . ($packageVersion ? " with version {$packageVersion}." : " with stability {$stability}."));
}
if (null === $directory) {
$parts = explode("/", $name, 2);
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
}
// handler Ctrl+C for unix-like systems
if (function_exists('pcntl_signal')) {
declare (ticks=100);
pcntl_signal(SIGINT, function () use($directory) {
$fs = new Filesystem();
$fs->removeDirectory($directory);
exit(130);
});
}
$io->writeError('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
if ($disablePlugins) {
$io->writeError('<info>Plugins have been disabled.</info>');
}
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
$package->setSourceReference(substr($package->getPrettyVersion(), 4));
}
$dm = $this->createDownloadManager($io, $config);
$dm->setPreferSource($preferSource)->setPreferDist($preferDist)->setOutputProgress(!$noProgress);
$projectInstaller = new ProjectInstaller($directory, $dm);
$im = $this->createInstallationManager();
$im->addInstaller($projectInstaller);
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
$im->notifyInstalls();
$installedFromVcs = 'source' === $package->getInstallationSource();
$io->writeError('<info>Created project in ' . $directory . '</info>');
chdir($directory);
$_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
putenv('COMPOSER_ROOT_VERSION=' . $_SERVER['COMPOSER_ROOT_VERSION']);
return $installedFromVcs;
}
示例10: installProject
public function installProject(IOInterface $io, $packageName, $directory = null, $version = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null)
{
$dm = $this->createDownloadManager($io);
if ($preferSource) {
$dm->setPreferSource(true);
}
$config = Factory::createConfig();
if (null === $repositoryUrl) {
$sourceRepo = new ComposerRepository(array('url' => 'http://packagist.org'), $io, $config);
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION)) {
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, new RemoteFilesystem($io)));
} elseif (0 === strpos($repositoryUrl, 'http')) {
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
} else {
throw new \InvalidArgumentException("Invalid repository url given. Has to be a .json file or an http url.");
}
$candidates = $sourceRepo->findPackages($packageName, $version);
if (!$candidates) {
throw new \InvalidArgumentException("Could not find package {$packageName}" . ($version ? " with version {$version}." : ''));
}
if (null === $directory) {
$parts = explode("/", $packageName, 2);
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
}
// select highest version if we have many
$package = $candidates[0];
foreach ($candidates as $candidate) {
if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
$package = $candidate;
}
}
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>', true);
$projectInstaller = new ProjectInstaller($directory, $dm);
$projectInstaller->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), $package);
$io->write('<info>Created project in ' . $directory . '</info>', true);
chdir($directory);
$composer = Factory::create($io);
$installer = Installer::create($io, $composer);
$installer->setPreferSource($preferSource)->setDevMode($installDevPackages)->run();
}
示例11: remove
public function remove(PackageInterface $package, $path)
{
$this->io->write(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
if (!defined('PHP_WINDOWS_VERSION_BUILD') || usleep(250000) && !$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete ' . $path . ', aborting.');
}
}
}
示例12: formatVersion
protected function formatVersion(PackageInterface $package)
{
return VersionParser::formatVersion($package);
}
示例13: installRootPackage
protected function installRootPackage(IOInterface $io, $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false)
{
if (null === $repositoryUrl) {
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION)) {
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, new RemoteFilesystem($io)));
} elseif (0 === strpos($repositoryUrl, 'http')) {
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
} else {
throw new \InvalidArgumentException("Invalid repository url given. Has to be a .json file or an http url.");
}
$parser = new VersionParser();
$candidates = array();
$requirements = $parser->parseNameVersionPairs(array($packageName));
$name = strtolower($requirements[0]['name']);
if (!$packageVersion && isset($requirements[0]['version'])) {
$packageVersion = $requirements[0]['version'];
}
if (null === $stability) {
if (preg_match('{^[^,\\s]*?@(' . implode('|', array_keys(BasePackage::$stabilities)) . ')$}i', $packageVersion, $match)) {
$stability = $match[1];
} else {
$stability = VersionParser::parseStability($packageVersion);
}
}
$stability = VersionParser::normalizeStability($stability);
if (!isset(BasePackage::$stabilities[$stability])) {
throw new \InvalidArgumentException('Invalid stability provided (' . $stability . '), must be one of: ' . implode(', ', array_keys(BasePackage::$stabilities)));
}
$pool = new Pool($stability);
$pool->addRepository($sourceRepo);
$constraint = $packageVersion ? $parser->parseConstraints($packageVersion) : null;
$candidates = $pool->whatProvides($name, $constraint);
foreach ($candidates as $key => $candidate) {
if ($candidate->getName() !== $name) {
unset($candidates[$key]);
}
}
if (!$candidates) {
throw new \InvalidArgumentException("Could not find package {$name}" . ($packageVersion ? " with version {$packageVersion}." : " with stability {$stability}."));
}
if (null === $directory) {
$parts = explode("/", $name, 2);
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
}
$package = reset($candidates);
foreach ($candidates as $candidate) {
if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
$package = $candidate;
}
}
unset($candidates);
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
if ($disablePlugins) {
$io->write('<info>Plugins have been disabled.</info>');
}
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
$package->setSourceReference(substr($package->getPrettyVersion(), 4));
}
$dm = $this->createDownloadManager($io, $config);
$dm->setPreferSource($preferSource)->setPreferDist($preferDist)->setOutputProgress(!$noProgress);
$projectInstaller = new ProjectInstaller($directory, $dm);
$im = $this->createInstallationManager();
$im->addInstaller($projectInstaller);
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
$im->notifyInstalls();
$installedFromVcs = 'source' === $package->getInstallationSource();
$io->write('<info>Created project in ' . $directory . '</info>');
chdir($directory);
putenv('COMPOSER_ROOT_VERSION=' . $package->getPrettyVersion());
return $installedFromVcs;
}
示例14: installProject
public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false)
{
$config = Factory::createConfig();
$dm = $this->createDownloadManager($io, $config);
if ($preferSource) {
$dm->setPreferSource(true);
}
if (null === $repositoryUrl) {
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION)) {
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, new RemoteFilesystem($io)));
} elseif (0 === strpos($repositoryUrl, 'http')) {
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
} else {
throw new \InvalidArgumentException("Invalid repository url given. Has to be a .json file or an http url.");
}
$candidates = array();
$name = strtolower($packageName);
if ($packageVersion === null) {
$sourceRepo->filterPackages(function ($package) use(&$candidates, $name) {
if ($package->getName() === $name) {
$candidates[] = $package;
}
});
} else {
$parser = new VersionParser();
$version = $parser->normalize($packageVersion);
$sourceRepo->filterPackages(function ($package) use(&$candidates, $name, $version) {
if ($package->getName() === $name && $version === $package->getVersion()) {
$candidates[] = $package;
return false;
}
});
}
if (!$candidates) {
throw new \InvalidArgumentException("Could not find package {$packageName}" . ($packageVersion ? " with version {$packageVersion}." : ''));
}
if (null === $directory) {
$parts = explode("/", $packageName, 2);
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
}
// select highest version if we have many
$package = $candidates[0];
foreach ($candidates as $candidate) {
if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
$package = $candidate;
}
}
unset($candidates);
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>', true);
if ($disableCustomInstallers) {
$io->write('<info>Custom installers have been disabled.</info>');
}
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
$package->setSourceReference(substr($package->getPrettyVersion(), 4));
}
$projectInstaller = new ProjectInstaller($directory, $dm);
$projectInstaller->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), $package);
if ($package->getRepository() instanceof NotifiableRepositoryInterface) {
$package->getRepository()->notifyInstall($package);
}
$io->write('<info>Created project in ' . $directory . '</info>', true);
chdir($directory);
putenv('COMPOSER_ROOT_VERSION=' . $package->getPrettyVersion());
// clean up memory
unset($dm, $config, $projectInstaller, $sourceRepo, $package);
// install dependencies of the created project
$composer = Factory::create($io);
$installer = Installer::create($io, $composer);
$installer->setPreferSource($preferSource)->setDevMode($installDevPackages)->setRunScripts(!$noScripts);
if ($disableCustomInstallers) {
$installer->disableCustomInstallers();
}
$installer->run();
}
示例15: remove
public function remove(PackageInterface $package, $path)
{
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete ' . $path . ', aborting.');
}
}