WordPress Security How To
WordPress Security How To

Install and update WP Cerber with Composer


If your WordPress project already manages plugins with Composer, you can install WP Cerber as a Composer package and keep up with our regular security and maintenance releases. You can test each update on staging before deploying the same version to production.

The package is wpcerber/wp-cerber on Packagist, the default package repository for Composer, so your project needs no custom repository. Releases are available through Composer starting with 10.0.0.

Packagist indexes the package from our public GitHub mirror at github.com/wpcerber/wp-cerber, which contains the unmodified files of each official release. If your project cannot use Packagist or GitHub, see Install from downloads.wpcerber.com instead at the end of this guide.

Configure your project

Composer places WP Cerber in the WordPress plugins directory through the composer/installers plugin. Composer 2.2 and later require explicit permission to run it. Add the following entry to your project’s root composer.json, preserving any existing plugin permissions.

{
  "config": {
    "allow-plugins": {
      "composer/installers": true
    }
  }
}

The installer resolves plugin paths relative to the directory that contains composer.json. Without a custom mapping, WP Cerber goes to wp-content/plugins/wp-cerber/ in that directory, which is correct only when composer.json sits in the WordPress root. If your composer.json is elsewhere, for example one level above the web root, map plugins to their actual location under extra.installer-paths.

{
  "extra": {
    "installer-paths": {
      "public_html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
    }
  }
}

Bedrock. The standard Bedrock configuration already maps packages of type wordpress-plugin to web/app/plugins/{$name}/, so WP Cerber installs in web/app/plugins/wp-cerber/. Keep that entry under extra.installer-paths.

Check the requirements

WP Cerber 10.0.0 requires WordPress 5.8 or later and PHP 7.4 or later. Later releases may raise these minimums.

Composer enforces the PHP requirement, but it compares it with the PHP version that runs Composer, not the one that serves your site. If you run Composer on a build server or in CI with a different PHP version, declare the production version in your project. Replace 8.2 with the PHP version of your production server.

composer config platform.php 8.2

Composer does not check the WordPress minimum at all. Each release declares it as Requires at least in the header of wp-cerber.php. After Composer installs a release on staging, compare that value with the WordPress version of your production site before you deploy.

Install and activate WP Cerber

Run this command from the directory containing composer.json to install the latest compatible 10.x release.

composer require "wpcerber/wp-cerber:10.*"

If you omit the version constraint, Composer writes ^10.0 to composer.json, which allows the same releases. Packagist also lists a dev-main version that follows the main branch of the mirror. Require a versioned release instead, so that your lock file and deployments refer to an identifiable release.

After the first installation, confirm that wp-cerber.php is in the plugins directory you expect. Composer places WP Cerber through the composer/installers plugin. When Composer runs as root in a non-interactive session, such as a container build, it disables plugins and installs WP Cerber in vendor/wpcerber/wp-cerber/ instead, with only a notice in the output. Run Composer as a regular user, or set the environment variable COMPOSER_ALLOW_SUPERUSER=1 if the build must run as root.

Commit composer.json and composer.lock together. On a fresh deployment, install the exact versions recorded in the lock file with this command.

composer install

On the site, open Plugins > Installed Plugins and activate WP Cerber Security. If you use WP-CLI, you can activate it with wp plugin activate wp-cerber.

Switch an existing installation to Composer

If WP Cerber is already installed on the site, Composer replaces the entire wp-cerber folder with the files of the release and removes any files that are not part of it. Composer does not touch the database, so your WP Cerber settings and logs stay in place. Because the folder and main file names stay the same, WordPress keeps the plugin active. Back up the database first and require a release that is not older than the one the site currently runs.

If the Git repository of your project tracks the plugins directory, remove wp-cerber from version control and add it to .gitignore. Otherwise, the committed copy and the Composer-managed copy compete for the same folder.

Update or roll back

Composer replaces only the plugin files. It does not back up or restore WP Cerber settings and data in the WordPress database, so back up the database before every update.

Use a package-specific update to install the latest WP Cerber release allowed by your project.

composer update wpcerber/wp-cerber

The 10.* constraint allows minor and patch releases within version 10. A new major version requires a new constraint. Test the update on staging, commit the changed composer.lock, and deploy it to production with composer install.

For tighter control, narrow the constraint to one release series. For example, 10.0.* accepts 10.0.1 and 10.0.2 but not 10.1.0. WP Cerber version numbers do not carry Semantic Versioning guarantees, so a narrower constraint reduces how often the plugin changes, not how much a single update can change. Review every update on staging whichever constraint you choose.

To pin WP Cerber to a specific release, specify its exact version. For example, this command pins WP Cerber to 10.0.0 and rolls back the plugin files if a later version is installed.

composer require "wpcerber/wp-cerber:10.0.0"

A rollback restores only the plugin files. It does not revert changes that the later release may have made to WP Cerber settings or database tables, so check that the older release works with the current data. Test the rollback on staging first. Restore the database backup only if the older release does not work with the data the later release left behind. Restoring the entire database also discards posts, orders, comments, and every other change made on the site since the backup was taken.

Commit both Composer files after changing the constraint. While the exact pin is in place, composer update keeps WP Cerber at 10.0.0. To resume 10.x updates, rerun the original composer require "wpcerber/wp-cerber:10.*" command.

Roll back with an exact version rather than by restoring an older composer.lock. An older lock file reverts every project dependency, not only WP Cerber.

Keep plugin updates under Composer’s control

WP Cerber has its own Automatically update WP Cerber setting under WP Cerber > Main Settings, in the Site-specific settings section. It is off by default, and it must stay off on Composer-managed sites. When enabled, it makes WordPress auto-update WP Cerber regardless of the plugin’s auto-update toggle in WordPress, so turning off WordPress auto-updates alone does not stop it. The setting is described in Automatic updates for WP Cerber.

Also turn off WordPress auto-updates for WP Cerber, for example with wp plugin auto-updates disable wp-cerber, and skip it when applying updates in the WordPress dashboard. Setting DISALLOW_FILE_MODS to true in wp-config.php blocks plugin updates and installations from the dashboard for all plugins. Bedrock sets this constant by default outside the development environment.

Cerber.Hub is a separate case. If you use Cerber.Hub, exclude Composer-managed sites from WP Cerber upgrades even when DISALLOW_FILE_MODS is set.

Check scheduled maintenance scripts for wp plugin update wp-cerber and wp plugin update --all. If the script also manages other plugins, add --exclude=wp-cerber to the bulk update. Avoid wp plugin install --force for WP Cerber. These operations can replace the plugin files without changing composer.lock. The site then runs a different version from the one you reviewed, and the next clean deployment restores the locked version.

A regular composer install on an existing deployment does not detect changed plugin files, because Composer considers the locked release already installed. To restore the locked release in place, reinstall the package.

composer reinstall wpcerber/wp-cerber

Keep translations up to date

WP Cerber release archives, and therefore the Composer package, contain no translations. WordPress downloads them separately from the WP Cerber Software Repository when the Use WP Cerber’s plugin repository setting is on. You find it under WP Cerber > Main Settings, in the Site-specific settings section. Keep this setting on for Composer-managed sites that use a language other than English. When it is off, WordPress receives neither plugin updates nor translation updates for WP Cerber. The translations already installed stay in place but fall behind as new releases add or change text.

With the setting on, the WordPress dashboard also announces new WP Cerber releases. Leave these updates to Composer as described above. WordPress stores the translations in its languages directory, outside the plugin folder, so Composer does not remove them when it replaces the plugin files.

DISALLOW_FILE_MODS blocks translation updates too, for WP Cerber and every other plugin. On a site with this constant set, translations for WP Cerber are not updated even when the setting is on.

Install from downloads.wpcerber.com instead

WP Cerber is also available to Composer directly from downloads.wpcerber.com, under the same package name and with the same version numbers. Both sources deliver the same release files, so everything else in this guide applies to either of them. Consider this source if the servers that run Composer cannot reach GitHub, or if you need a new release before it appears on Packagist. A release is published on downloads.wpcerber.com first and reaches the GitHub mirror afterward.

downloads.wpcerber.com hosts the WP Cerber Software Repository, described below. For Composer, it provides package metadata at https://downloads.wpcerber.com/versions.

To use this source, add its address to repositories in your project’s root composer.json before you require the package. Put this entry first and keep your other entries.

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://downloads.wpcerber.com/versions"
    }
  ]
}

Composer does not combine the two sources. While this entry is in place, Composer takes wpcerber/wp-cerber from downloads.wpcerber.com alone and does not look for the package on Packagist.

The lock file identifies the release differently for each source. With downloads.wpcerber.com, it records the SHA-1 checksum of the release archive, and Composer refuses to install an archive that does not match it. With Packagist, it records the commit of the GitHub mirror that holds the release.

This is a check that Composer performs on the downloaded archive at installation time. It is unrelated to the WP Cerber integrity scanner, which verifies the installed plugin files on the site whichever source they came from.

Switch an existing project between the sources

To move a project to the other source, add or remove the downloads.wpcerber.com entry under repositories in composer.json and update the package.

composer update wpcerber/wp-cerber

Composer records the new source in composer.lock and reinstalls the plugin folder. Commit the updated lock file. Running composer install instead keeps the old source and only warns that the lock file is out of date.

The update selects the newest release that the new source lists and your constraint allows. Because Packagist can lag behind downloads.wpcerber.com, a project switched to Packagist right after a release may move back to the previous version. Check the version in the output, and do the switch on staging first.

What the WP Cerber Software Repository is

The WP Cerber Software Repository is the official distribution server for WP Cerber, located at downloads.wpcerber.com. It holds the release archives of the plugin and delivers updates and translations to the WP Cerber dashboard. WP Cerber has used it by default since version 9.2. You can disable its use on individual sites through the Use WP Cerber’s plugin repository setting.

The same server supplies the Composer metadata and archives described in the previous section. Composer reads them directly, without involving the plugin, so the setting has no effect on Composer installations.

For the background and security details of the repository, see WP Cerber Software Repository.

Have any questions?

If you have a question regarding WordPress security or WP Cerber, leave them in the comments section below or get them answered here: G2.COM/WPCerber.


I'm a team lead in Cerber Tech. I'm a software & database architect, WordPress - PHP - SQL - JavaScript developer. I started coding in 1993 on IBM System/370 (yeah, that was amazing days) and today software engineering at Cerber Tech is how I make my living. I've taught to have high standards for myself as well as using them in developing software solutions.

View Comments
There are currently no comments.