Composer 1.3.0 or later is installed in local development and production environments.
I’ll be using Pixel & Tonic’s Redactor plugin as an example. The latest version (at time of writing) is 2.8.5 as per the Redactor plugin page in the Craft Plugin Store.
composer require craftcms/redactor:2.8.5
to add the Redactor Composer package to the composer.json
file and install it with the version constrained to 2.8.5.craft plugin/install redactor
to install the Redactor plugin with handle redactor
in Craft itself../craft migrate/all
to run plugin database migrations../craft project-config/apply
to apply project config file changes../craft clear-caches/all
to clear all the caches../craft backup
to backup the Craft database.composer install
to install the plugin Composer package that I previously installed in my local development environment../craft migrate/all
to run all database migrations../craft project-config/apply
to apply project config file changes../craft clear-caches/all
to clear all the caches.From the command line in the Craft project root, run:
craft plugin/uninstall redactor
to uninstall the Redactor plugin with handle redactor
.composer remove craftcms/redactor
to remove the Redactor Composer package from the composer.json
file../craft backup
to backup the Craft database.composer install
to uninstall the plugin Composer package that I previously uninstalled in my local development environment../craft migrate/all
to run all database migrations../craft project-config/apply
to apply project config file changes../craft clear-caches/all
to clear all the caches.To avoid running the above Craft CLI commands manually, I’ve added the following Composer command events with the relevant Craft CLI commands to the scripts
section of my Craft project’s composer.json
file.
"pre-update-cmd": [
"@php craft backup/db"
],
"post-update-cmd": [
"@php craft migrate/all",
"@php craft project-config/apply",
"@php craft clear-caches/all"
],
"pre-install-cmd": [
"@php craft backup/db"
],
"post-install-cmd": [
"@php craft migrate/all",
"@php craft project-config/apply",
"@php craft clear-caches/all"
]
By following the steps above, I can confidently install Craft plugins in my local development and production environments.
To learn how I update plugins, read my article titled How I Update Craft CMS 3.5.x and Craft CMS Plugins.
— Andrea