Confused on how exactly plugins are installed with Composer?


I’m using Composer to install plugins with the wpackagist repository. I’ve added all the relevant lines to my composer.json file in my main wp/ directory.

The plugin installed as expected (it’s this one if it makes any difference) to its own folder within wp/plugins/.

The issue that I see now is that it doesn’t show up in the plugins section of my WordPress dashboard, nor am I able to install it with wp plugin activate <name>.

Is there something else that needs to be done with Composer or elsewhere in this process to allow the plugin to be able to be installed? I’ve looked through the guide to Composer on this site, but I don’t see anything in there that I haven’t already done.

Are you using Bedrock?

WordPress doesn’t use Composer by default so not exactly sure what you’re referring to.

Sorry, yes I’m using Sage + Trellis which seems to be using Composer as many directories have a composer.json file.

Some of this depends on how your project is configured, but it’s Bedrock specifically that uses Composer to manage plugins, and you only mention using Sage & Trellis.

I’m not sure how you’ve configured Trellis, but generally plugins should be getting installed to a directory that looks something like project_root/site/web/app/plugins/, not under any wp directory—the wp directory is just for WordPress Core files in the Roots stack: You shouldn’t ever be doing anything (except occasionally updating WordPress) that modifies the files in that folder.

Assuming you’re using Bedrook, you’d want to be editing the composer.json that’s in a directory kind of like this; project_root/site/.

Apart from that, the process you’ve described is correct: You add the plugin to your composer.json, run composer update, and the plugin will get installed and appear in your WordPress installation. So my guess would be that you’re just editing the wrong composer.json.

1 Like

Thanks! Worked perfectly. There are just so many composer.json files that I was confused which was which.