From 31cf6788e609c19c471b3c4f550a7302c187d6e6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 13 Oct 2020 11:05:37 +0200 Subject: [PATCH] Improve plugin docs --- doc/articles/plugins.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/articles/plugins.md b/doc/articles/plugins.md index 28b7c1475..97ebd67e1 100644 --- a/doc/articles/plugins.md +++ b/doc/articles/plugins.md @@ -161,6 +161,14 @@ class AwsPlugin implements PluginInterface, EventSubscriberInterface $this->io = $io; } + public function deactivate(Composer $composer, IOInterface $io) + { + } + + public function uninstall(Composer $composer, IOInterface $io) + { + } + public static function getSubscribedEvents() { return array( @@ -175,9 +183,7 @@ class AwsPlugin implements PluginInterface, EventSubscriberInterface $protocol = parse_url($event->getProcessedUrl(), PHP_URL_SCHEME); if ($protocol === 's3') { - $awsClient = new AwsClient($this->io, $this->composer->getConfig()); - $s3Downloader = new S3Downloader($this->io, $event->getHttpDownloader()->getOptions(), $awsClient); - $event->setHttpdownloader($s3Downloader); + // ... } } } @@ -263,7 +269,7 @@ Now the `custom-plugin-command` is available alongside Composer commands. ## Running plugins manually -Plugins for an event can be run manually by the `run-script` command. This works the same way as +Plugins for an event can be run manually by the `run-script` command. This works the same way as [running scripts manually](scripts.md#running-scripts-manually). ## Using Plugins @@ -278,6 +284,12 @@ local project plugins are loaded. > installed plugins. This may be particularly helpful if any of the plugins > causes errors and you wish to update or uninstall it. +## Plugin Helpers + +As of Composer 2, due to the fact that DownloaderInterface can sometimes return Promises +and have been split up in more steps than they used to, we provide a [SyncHelper][11] +to make downloading and installing packages easier. + [1]: ../04-schema.md#type [2]: ../04-schema.md#extra [3]: https://github.com/composer/composer/blob/master/src/Composer/Plugin/PluginInterface.php @@ -288,3 +300,4 @@ local project plugins are loaded. [8]: https://github.com/composer/composer/blob/master/src/Composer/Plugin/Capable.php [9]: https://github.com/composer/composer/blob/master/src/Composer/Plugin/Capability/CommandProvider.php [10]: https://symfony.com/doc/current/components/console.html +[11]: https://github.com/composer/composer/blob/master/src/Composer/Util/SyncHelper.php