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

Composer 2 support #47

Closed
Seldaek opened this issue May 1, 2020 · 3 comments
Closed

Composer 2 support #47

Seldaek opened this issue May 1, 2020 · 3 comments

Comments

@Seldaek
Copy link

Seldaek commented May 1, 2020

As composer 2 is coming, it would be good to support it here.

From looking at your code, IMO the best way would be to tag a new release 2.0, which supports Composer 1, and 2 together. You can check if (defined('Composer\Composer::RUNTIME_API_VERSION') && version_compare(Composer\Composer::RUNTIME_API_VERSION, '2.0', '>=')) { ..composer2 behavior .. } else { composer 1..}

For v2, you can not just call download as in https://github.com/jakoch/phantomjs-installer/blob/master/src/PhantomInstaller/Installer.php#L190 - that will not do what you want anymore, and it uses async code which is rather messy to tap into like that.

You should instead do this:

$loop = $composer->getLoop()
$promise = $installationManager->download($package, $targetDir);
if ($promise) {
    $loop->wait(array($promise));
}
$promise = $installationManager->prepare('install', $package, $targetDir);
if ($promise) {
    $loop->wait(array($promise));
}
$promise = $installationManager->install($package, $targetDir);
if ($promise) {
    $loop->wait(array($promise));
}
$promise = $installationManager->cleanup('install', $package, $targetDir);
if ($promise) {
    $loop->wait(array($promise));
}

As an aside, I wonder if it wouldn't be better to let users specify the version they want to install in the root package's extra (like you have cdnurl option right now), instead of having a direct mapping of package version to phantomjs version..

@jakoch
Copy link
Owner

jakoch commented May 1, 2020

Thank you for looking at the code and providing these upgrade hints, Jordi! ❤️

$loop = $composer->getLoop()

Whoaa.. this is new! Finally, we can reach the inner download loop.

let users specify the version they want to install in the root package's extra

Yes, that's way cleaner and also easy to add. TY for the suggestion.

@dereuromark
Copy link

Hey guys
We checked composer v2 compatibility and stumbled upon this ticket.
It seems this one here is the only issue left for us to try and use v2.

Is there any plan from your side to release a new version here based on the fix above?
Thank you!

jakoch added a commit that referenced this issue Jul 18, 2020
jakoch added a commit that referenced this issue Jul 18, 2020
- stop testing on PHP5
- raise PHPUnit to "^8" (support for PHP 7.1-7.4)
- migrate to PHPUnit 6+ (\PHPUnit\Framework\TestCase + setUp():void)

- updated Changelog + Readme section on how to require a specific phantomjs version
@jakoch
Copy link
Owner

jakoch commented Jul 18, 2020

Composer 2 support landed.

I removed the direct mapping of package version to phantomjs version.
To indicate the BC break i tagged the version as v3.0.0.

@jakoch jakoch closed this as completed Jul 18, 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

3 participants