Skip to content

6. Composer

alex_prokopenko edited this page Dec 4, 2017 · 4 revisions

Composer is used to manage dependencies. We consides any 3rd party library as a dependency including WordPress itself and any plugins.

See these resources for more extensive documentation:

Plugins

WordPress Packagist is already registered in the composer.json file so any plugins from the WordPress Plugin Directory can easily be required.

To add a plugin, add it under the require directive or use composer require <namespace>/<packagename> from the command line. If it's from WordPress Packagist then the namespace is always wpackagist-plugin.

Example: "wpackagist-plugin/akismet": "dev-trunk"

Whenever you add a new plugin or update the WP version, run composer update to install your new packages.

plugins, and mu-plugins are not Git globally ignored by default *. This is done because not every WordPress Plugin are managed well, has versions (tags) and can be downgraded easily. Unfortunately with WordPress there is a possibility that a new plugin update will break your site. Because of that we recommend to keep plugins in the repository as well. Of course you can Git ignore popular and trusted plugins by yourself to keep repository clean, you need to update .gitignore to ignore them:

wp-content/plugins/plugin-name

*Note: We git-ignored some of the popular plugins, which we trust and already added to composer.json.

Updating WP and plugin versions

Updating your WordPress version (or any plugin) is just a matter of changing the version number in the composer.json file.

Then running composer update will pull down the new version.

Themes

Themes can also be managed by Composer but should only be done so under two conditions:

  1. You're using a parent theme that won't be modified at all
  2. You want to separate out your main theme and use that as a standalone package

Just like plugins, WPackagist maintains a Composer mirror of the WP theme directory. To require a theme, just use the wpackagist-theme namespace.


Next: Security

Clone this wiki locally