• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / Composer WordPress.org Plugins

Composer WordPress.org Plugins

Last updated on March 10, 2017 by Sal Ferrarello


Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 12 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 14 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 15 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 27 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 29 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 30 in /home/customer/www/salferrarello.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466

I’ve recently been introduced to managing WordPress.org plugins via Composer. This makes it more convenient when excluding plugins from your working repository. Composer is capable of doing far more than managing plugins but at this point, that is the extent of how I’m using it.

This allows me to exclude my plugins via .gitignore yet check in my composer.json file, allowing me to quickly install the correct plugins in a newly cloned instance.

Install Composer

You can install composer with the following line.

curl -sS https://getcomposer.org/installer | php;mv composer.phar /usr/local/bin/composer

Composer Configuration

Create a file called composer.json in the root of your project. This file includes the list of plugins you want to manage via Composer. Here is an example file that manages two plugins WordPress SEO and Simple Google Analytics Tracking.

{
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
}
],
"require": {
"wpackagist-plugin/wordpress-seo":">1.7.3",
"wpackagist-plugin/simple-google-analytics-tracking":">1.0"
}
}
view raw composer.json hosted with ❤ by GitHub

Install Plugins

After your composer.json file is in place, from the command line run

composer install

This reads your composer.json file and creates your plugins in the wp-content/plugins/ directory.

The install command also creates a directory called vendor. You can ignore this directory, both in the sense of not paying attention to it and making sure your .gitignore excludes it from your repository.

Plugins Not on WordPress.org

For plugins not on WordPress.org, Composer can be used to load the plugin directly from a Git repo. I wrote about how I do this in my post Loading a Private WordPress Plugin with Composer.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Dev Tips, Programming Tagged With: composer, WordPress, WordPress Plugin

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in