FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
Composer and WordPress
Managing Themes and Plugins (for entire WordPress site)
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Managing WordPress.org hosted themes and plugins
Adding wpackagist.org repository to composer.json
Adding actual wordpress.org themes and plugins
Managing non-WordPress.org themes and plugins
Theme/Plugin published as composer package via packagist.org
Theme/Plugin under version control – with composer support
Theme/Plugin under version control – without composer support
Theme/Plugin without version control e.g. zip file
Note about private git/svn repos
Summary
Managing Themes and Plugins (for entire WordPress site)
As our basic composer project is ready with desired version of WordPress, we can proceed to add themes and plugin to our project.
As WordPress ecosystem has tons of free and paid themes/plugins from different sources, we need to follow few different methods to handle them. We will see them one-by-one.
Managing WordPress.org hosted themes and plugins
Composer makes it easy to use anything as dependency, even if target library/repo is not a composer package!
This involves fair amount of work, as we will see later in this chapter alone. But thanks to wpackagist.org – a composer package repository created by fine folks at Outlandish, working with WordPress.org hosted themes and plugins becomes cakewalk!
wpackagist.org homepage explains usage in nice details but we will try to over-simplify things for composer newbies here by breaking process in two steps.
Adding wpackagist.org repository to composer.json
Composer by default only looks for packages hosted on packagist.org. So first thing we need to tell composer is to look for WordPress themes and plugins at wpackagist.org. This can be done by adding following lines to composer.json file:
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
}
],
You can add above lines automatically by running command composer config repositories.0 composer https://wpackagist.org/ So composer.json file will look like:
{
"name": "rtcamp/wordpress-composer-template",
"description": "Using Composer to manage complete WordPress Project",
"license": "MIT",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
"require": {
"johnpbloch/wordpress": "4.2.2",
}
}
Adding actual wordpress.org themes and plugins
Each wordpress theme and plugin has a unique slug. You can use that slug to search theme/plugin on wpackagist.org. wpackagist.org will show you a result page with versions available trough composer. You can click on a version and composer will give one-line statements like:
"wpackagist-plugin/nginx-helper": "1.9.3"– for nginx-helper plugin"wpackagist-theme/twentyfifteen": "1.2"– for twentyfifteen theme
You can copy code blocks to require section in composer.json like below:
{
"name": "rtcamp/wordpress-composer-template",
"description": "Using Composer to manage complete WordPress Project",
"license": "MIT",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
"require": {
"johnpbloch/wordpress": "4.2.2",
"wpackagist-theme/twentyfifteen": "1.2",
"wpackagist-plugin/nginx-helper": "1.9.3"
}
}
Once composer.json file is updated, you can run composer install/update to download dependencies. Command Line Way Alternatively, you can run following composer command to add dependency without opening composer.json file
composer require wpackagist-theme/twentyfifteen:1.2 wpackagist-plugin/nginx-helper:1.9.3
Please note that composer require will update composer.json and also download packages right away. If you want to prevent automatic downloading of dependencies, you can pass flag --no-update to above command.
Managing non-WordPress.org themes and plugins
Unlike above, this is very broad. Mainly we need to deal with:
- Theme/Plugin published as composer package via packagist.org
- Theme/Plugin under version control – with composer support
- Theme/Plugin under version control – without composer support
- Theme/Plugin without version control e.g. zip file
Let’s deal with each of above with an example.
Theme/Plugin published as composer package via packagist.org
As an example, let’s use github-updater WordPress plugin which is not allowed on wordpress.org repo but available as composer package at – https://packagist.org/packages/afragen/github-updater You can add a line like below to composer.json file’s require section and it will work just fine
"afragen/github-updater": "^4.6"
Or can run composer command composer require afragen/github-updater
Above works so easily because github-updater is composer package. Things will not be easy for remaining cases!
Theme/Plugin under version control – with composer support
There could be a case that a project is neither hosted on wordpress.org or in some composer repo but still has composer.json in it.
As an example consider this plugin – https://github.com/rtCamp/rtAntiSpam we use on our sites but did not release it on wordpress.org! This plugin has a composer.json file you may like to have a look at.
To install such theme/plugin, we need to perform two steps:
Add version control project as a new composer repository (like wpackagist.org)
We can do that by adding following to composer.json file:
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org/"
},
{
"type": "vcs",
"url": "git@github.com:rtCamp/rtAntiSpam.git"
}
],
Please note that repo type isvcs (or we can use git). For wpackagist.org it wascomposer since wpackagist.org is a composer repository.
Above can be done via command line as well:
composer config repositories.rtantispam vcs git@github.com:rtCamp/rtAntiSpam.git
Adding repos via command updates composer.json file in slight different way:
"repositories": {
"0": {
"type": "composer",
"url": "https://wpackagist.org/"
},
"rtantispam": {
"type": "vcs",
"url": "git@github.com:rtCamp/rtAntiSpam.git"
}
},
The difference really don’t matter so ignore it if it’s not making sense.
Add actual composer package
Once we add our git repo, we can add it as a package like below.
"require": {
"rtcamp/rtantispam": "dev-master"
}
dev-master will point to git’s master branch. This is really bad practise but we are explaining it this way because many developers (including us) do not use git tags for internal projects. 😐
For command-line interface, we can achieve above by running:
composer require rtcamp/rtantispam:dev-master
If you have taken look at composer.json for rtAntiSpam plugin, you may notice it has package name equal to rtcamp/rtantispam.
We need to match package name with composer.json.
Please note that composer.json in your project is different than composer.json in other project.
Theme/Plugin under version control – without composer support
Composer allow you to dynamically include any version controlled repo as a package, even if destination doesn’t contain composer.json file!
As an example, we will use a plugin which is neither hosted on wordpress.org, nor has composer.json.
Again this will need two steps.
Add version control project as a new composer repository
{
"type": "package",
"package": {
"name": "digitalmedia/rollbar",
"type": "wordpress-plugin",
"version": "dev-master",
"source": {
"type": "git",
"url": "git@github.com:digitalmedia/rollbar.git",
"reference": "master"
}
}
}
If you have taken look at composer.json for rtAntiSpam then some fields like name and type are similar.
You may notice repo type is now package, earlier it was vcs and before that it was composer. So when a target repo is not a composer package, we can declare it as a package on our own end by adding it to repositories list.
To avoid confusion and clear context, below is complete repositories block from composer.json
"repositories": {
"0": {
"type": "composer",
"url": "https://wpackagist.org/"
},
"rtantispam": {
"type": "vcs",
"url": "git@github.com:rtCamp/rtAntiSpam.git"
},
"rollbar":{
"type": "package",
"package": {
"name": "digitalmedia/rollbar",
"type": "wordpress-plugin",
"version": "dev-master",
"source": {
"type": "git",
"url": "git@github.com:digitalmedia/rollbar.git",
"reference": "master"
}
}
}
},
Notes:
- In reality, package type
wordpress-pluginhas dependency oncomposer/installersbutwordpress-corecomposer package already satisfies it. So we are avoid duplicate lines in our composer.json file to keep it lean. - We really don’t know how to define entire package via composer command. But as you can see it has plenty of lines, we will prefer to copy-paste and edit.
- Composer doesn’t directly support custom path if package doesn’t have
composer.jsonin it’s source code withcomposer/installersas dependency but because we are usingwpackagistif we specify “type"as “wordpress-plugin"or “wordpress-theme"it will take care of it.
Add actual composer package
Once we add our git repo, we can add it as a package like below.
"require": {
"digitalmedia/rollbar": "dev-master"
}
dev-master will point to git’s master branch. Rollbar git repo also doesn’t have any tags. For command-line interface, we can achieve above by running:
composer require digitalmedia/rollbar:dev-master
Note: when defining package like this, you can use any package name. It no need to be githuborg/githubrepo. Only care you need to take is to keep githubrepo unique so it won’t conflict with any other WordPress package.
Theme/Plugin without version control e.g. zip file
This applies to packages available without any version control. This is common for premium themes and plugins which are often delivered as zip file.
For sake of example, let’s take example of our premium product rtBiz Helpdesk. We sell this plugin using easydigitaldownloads.com which generates a zip file link like below for each download:
https://easyengine.io/index.php?eddfile=[FILE]&ttl=[TTL]&file=0&token=[TOKEN]
We can add such zip file links directly as a composer package by following two steps like above.
Add zip file as a new composer repository
{
"type": "package",
"package": {
"name": "rtcamp/rtbiz-helpdesk",
"type": "wordpress-plugin",
"version": "1.0.0",
"dist": {
"type": "zip",
"url": "https://easyengine.io/index.php?eddfile=[FILE]&ttl=[TTL]&file=0&token=[TOKEN]"
}
}
}
Above example will look familiar.
Notes:
- If you do not have a unique download link for zip file, you can upload zip file on a private server and use that link. As long as it’s a valid link, composer won’t complain.
- You may notice version field is set to 1.0.0. This won’t matter as zip packages won’t have version control data. You may keep this version updated to remind yourself which package version you are using.
Add actual composer package
Once we add our zip repo, we can add it as a package like below.
"require": {
"rtcamp/rtbiz-helpdesk": "dev-master"
}
Again version won’t matter for zip files. For command-line interface, we can achieve above by running:
composer require rtcamp/rtbiz-helpdesk:dev-master
Note about private git/svn repos
Composer can works transparently with private git/svn repo, provided machine on which composer running is pre-authenticated.
As an example, if you are cloning git repos from Github using git-based URL and SSH public key for that machine is already added to your Github profile, composer will work without any issue.
Please avoid HTTP based URLs when defining vcs repositories in composer.
Summary
As you can see, we tried to cover all cases so you can define all themes and plugins as composer dependency and manage entire WordPress projects from a single composer.json file.
Composer by default will only download dependencies. In next chapter, we will deal with theme/plugin activation, again with the help of composer!
Updating Themes and Plugins (for entire WordPress site)
NEXT
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
URL
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.