Preferred way to install and uninstall plugins

Hi, there.

I just started using bedrock.

I saw there are two ways to install/uninstall wordpress plugins.

  1. With composer and wppackagist
  2. Using wp-cli

Installing using Composer :
composer require wpackagist-plugin/akismet
Above command will create an entry in composer.json and copy the plugin to web/app/plugins
We can activate the plugin manually.

Installing using WP CLI :
wp plugin install akismet
Above command will NOT create any entry in composer.json and copy the plugin to web/app/plugins

Remove using Composer:
composer uninstall wpackagist-plugin/akismet
Above command will delete entry from composer.json and also delete the files related to this plugin.
But this will not trigger the uninstall.php file.
Plugin authors uses the uninstall.php file to remove database entries created by plugin.

Uninstall using WP-CLI:
wp plugin uninstall akismet
Above command has nothing to do with composer, it will delete the files related to this plugin. Plus this will trigger the uninstall.php which will delete database entries also. i.e. Complete uninstall can be done only via wp-cli.

I really want to use composer because of composer.json.
How do you do this guys ?

Thanks.

I really want to use composer because of composer.json.

Then use Composer :slight_smile:

I personally use WP-CLI when I’m installing plugins on development to test them out and then use Composer to commit them to the project, which gets pushed to staging/production.

If you find yourself removing plugins once they’ve gone live you could SSH into the staging/production server(s) and use WP-CLI to uninstall them (cleanly), then on your development machine use the composer uninstall command to remove the plugin folder and entry in composer.json.