-
Notifications
You must be signed in to change notification settings - Fork 25
6. Composer
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:
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 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 can also be managed by Composer but should only be done so under two conditions:
- You're using a parent theme that won't be modified at all
- 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