clue / phar-composer

Simple phar creation for every PHP project managed via Composer
https://clue.engineering/2019/introducing-phar-composer
MIT License
855 stars 78 forks source link

Composer v2 compatibility #108

Closed nargotik closed 3 years ago

nargotik commented 3 years ago

Resolution of #106 and #105

As on composer 2 installed.json comes with an new index [packages] instead of root

This code would not iterate between packages

foreach ($installed as $package) {

by adding this line before would make this composer 2 compatible and keep backward also:

$installed = is_array($installed['packages']) ? $installed['packages'] : $installed;
nargotik commented 3 years ago

Resolution of #106 and #105

As on composer 2 installed.json comes with an new index [packages] instead of root

This code would not iterate between packages

foreach ($installed as $package) {

by adding this line before would make this composer 2 compatible and keep backward also:

$installed = is_array($installed['packages']) ? $installed['packages'] : $installed;

maybe this would be also a good aproach

$installed = empty($installed['packages']) ? $installed : $installed['packages'];
PurHur commented 3 years ago

Looks like #107 was faster. Probably you both should merge your PRs?

nargotik commented 3 years ago

Looks like #107 was faster. Probably you both should merge your PRs?

Yup only saw it after have done the pull request. From what i see @thojou looks more complete solution because he did the tests.

Personally thinking, the real solution is one line code don't need to do another call to check if is v2 if that new method only has one line of code, but that's a point of view.

Just hoping that one or another solution gets in production because phar-composer is not working in composer v2

clue commented 3 years ago

@nargotik Thanks for looking into this! I've just fixed this via #114. :shipit: