Skip to content

Commit

Permalink
Add support for Composer version 2
Browse files Browse the repository at this point in the history
Composer version 2 has `composer-plugin-api` version 2. This PR updates the version constraint to `^1 || ^2` so we can support both composer versions.

See [What's new in Composer 2](https://php.watch/articles/composer-2) and [UPGRADE-2.0](https://github.com/composer/composer/blob/master/UPGRADE-2.0.md#for-integrators-and-plugin-authors) for more changes in API. Empty methods \cweagans\Composer\Plugin\Patches::deactivate() and \cweagans\Composer\Plugin\Patches::uninstall are added to make it compatible both versions.
  • Loading branch information
Ayesh committed Apr 14, 2020
1 parent d9d6127 commit 7ee3bb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require": {
"php": ">=5.6.0",
"ext-json": "*",
"composer-plugin-api": "^1.0",
"composer-plugin-api": "^1.0 || ^2.0",
"cweagans/composer-configurable-plugin": "^1.0"
},
"require-dev": {
Expand Down
14 changes: 14 additions & 0 deletions src/Plugin/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,18 @@ protected function executeCommand($cmd)
}
return ($this->executor->execute($command, $output) === 0);
}

/**
* {@inheritDoc}
*/
public function deactivate(Composer $composer, IOInterface $io)
{
}

/**
* {@inheritDoc}
*/
public function uninstall(Composer $composer, IOInterface $io)
{
}
}

2 comments on commit 7ee3bb5

@staabm
Copy link

@staabm staabm commented on 7ee3bb5 Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we get a new release of composer-patches 1.x? we would love to use this plugin with composer v2 :-)

@cweagans
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staabm if you need Composer 2 support, I recommend using 1.x-dev for the time being. I'm not completely convinced that this is all that is needed to support Composer 2, so having some real usage with it would be great.

Please sign in to comment.