Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Composer 2 #611

Closed
nicolas-grekas opened this issue Apr 2, 2020 · 9 comments
Closed

Add support for Composer 2 #611

nicolas-grekas opened this issue Apr 2, 2020 · 9 comments

Comments

@nicolas-grekas
Copy link
Member

As hinted in composer/composer#8726

@Jean85
Copy link

Jean85 commented Apr 7, 2020

IIRC Composer 2 has parallel download, so that feature could be dropped/disabled in that case, right?

@Seldaek
Copy link
Member

Seldaek commented Apr 7, 2020

Yup the hope is that the flex integration for v2 can be done way less intrusively (no replacing of composer repo, no parallel download hijacking).

@stof
Copy link
Member

stof commented Apr 7, 2020

Features of Flex:

  • parallel download => native in composer 2
  • flex aliases for package names in composer require, update and remove
  • limiting available versions for Symfony packages (except for outdated)
  • customizing the defaults for various commands:
    • --remove-vcs for create-project
    • --no-suggests for update and require => solved in composer 2 as it does not show the full list anymore
    • weird change of the stability map for --prefer-lowest
  • new commands to manage recipes, dumping env file and unpacking packs
  • applying recipes after installing packages
  • @auto-scripts scripts, which have a Flex-specific syntax (main reason why Flex is not a dev requirement only, even if we exclude the parallel downloading feature)
  • customizing the composer.json after creating a project (changing the license to proprietary for instance)
  • adding a check for the PHP version in the autoload file
  • display a reminder message about symfony/thanks after update

All features starting from applying recipes after installing packages are built based on composer events, so a non-intrusive way already.
For new commands, Composer 1.1+ has a proper plugin API for that. I think it is fine to drop support for Composer 1.0 in Flex to use that API. Composer 1.1.0 has been released in May 2016 (btw, I'm not even sure older Composer version work fine today on modern PHP 7 versions and with the latest Packagist).

This leaves a few things that should be check for intrusiveness.

For limiting the versions, maybe some hooks in the new PoolBuilder could achieve it rather than replacing repositories.

@Seldaek
Copy link
Member

Seldaek commented Apr 7, 2020

  • flex aliases I am not sure how they are implemented, this is the part that I am least sure about how it will go with v2, hopefully won't be an issue.
  • limiting available versions is now easy we added a new event to do this much more cleanly, although I'd also hope it's less necessary than it was due to optimizations we did (hopefully more to come still)
  • customizing default IMO is a bad idea.. it just doesn't seem worth it, and it makes using flex potentially surprising and weird. I'd remove this, especially as --no-suggests is now gone, and the others are really minor wins
  • the php version check we are planning on adding this natively for 2.0, but it's not in yet. See Implemented php version check in autoload.php composer/composer#8546

The rest are simple events/commands as @stof said that's nothing special.

@stof
Copy link
Member

stof commented Apr 9, 2020

@Seldaek see

protected function execute(InputInterface $input, OutputInterface $output)
{
$packages = $this->resolver->resolve($input->getArgument('packages'), true);
if ($packages) {
$versionParser = new VersionParser();
$op = new Operation($input->getOption('unpack'), $input->getOption('sort-packages') || $this->getComposer()->getConfig()->get('sort-packages'));
foreach ($versionParser->parseNameVersionPairs($packages) as $package) {
$op->addPackage($package['name'], $package['version'] ?? '', $input->getOption('dev'));
}
$unpacker = new Unpacker($this->getComposer(), $this->resolver);
$result = $unpacker->unpack($op);
$io = $this->getIO();
foreach ($result->getUnpacked() as $pkg) {
$io->writeError(sprintf('<info>Unpacked %s dependencies</>', $pkg->getName()));
}
$input->setArgument('packages', $result->getRequired());
} elseif ($input->getOption('unpack')) {
$this->getIO()->writeError('<error>--unpack is incompatible with the interactive mode.</>');
return 1;
}
for the implementation of aliases in require

@Seldaek
Copy link
Member

Seldaek commented Apr 9, 2020

Ah ok so it's only modifying inputs, that sounds harmless enough but I guess someone will have to try it.

@stof
Copy link
Member

stof commented Apr 10, 2020

To change the argument, I'm quite sure the ConsoleEvents::COMMAND event from symfony/console 2.3+ would allow achieving it, assuming that composer plugins have access to it.

@Nyholm
Copy link
Member

Nyholm commented Jun 14, 2020

#617 is merged. This issue can be closed.

@nicolas-grekas
Copy link
Member Author

weird change of the stability map for --prefer-lowest

e.g. the stability of 5.1-dev is higher than 5.1-beta|alpha|rc, that's what this does.

tgalopin pushed a commit to tgalopin/flex that referenced this issue Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants