WP Rocket installation from GitHub using Composer

WP Rocket can be installed directly from our GitHub repository:

https://github.com/wp-media/wp-rocket

Requirements:

  • Composer - this has to be installed on the PC/server where you are planning to install WP Rocket.
  • PHP 7.3 or greater - this is necessary to run Mozart, one of the dependencies, i.e. it's not WP Rocket's minimum supported PHP version.

Installation

To install WP Rocket from GitHub follow these steps:

  1. Copy WP Rocket’s installation folder in the /wp-content/plugin/ folder either by downloading and unzipping the plugin’s file:

https://github.com/wp-media/wp-rocket/archive/trunk.zip

or by using git:

git clone https://github.com/wp-media/wp-rocket.git
  1. In the terminal navigate to /wp-content/plugins/wp-rocket/
  2. Run the following command:
  3. composer install --no-dev --no-scripts
    	

This will create a /vendor/ folder in WP Rocket’s root folder. It will include the 3rd-party libraries that WP Rocket uses.

Using composer at the root of a project?

The previous steps will work for installing the plugin via GitHub and running composer inside WP Rocket's plugin folder. 

But if you are using Composer at the root of your project, you will need to add the following line so it is present early in the WordPress loading process. For example, in your wp-config.php file :

require __DIR__ . '/vendor/autoload.php';
	

This will prevent issues with incorrect paths, that might cause the /vendor folder to end up being created outside the WP Rocket folder.
For further information: https://composer.rarst.net/recipe/site-stack/

WP Rocket's license

To add your license's info you'll have to define the following two constants in the  wp-config.php file:

define( 'WP_ROCKET_EMAIL', 'YOUR_ACCOUNT_EMAIL');
define( 'WP_ROCKET_KEY', 'YOUR_API_KEY');

Replace:

  • YOUR_ACCOUNT_EMAIL with the email of your WP Rocket account.
  • YOUR_API_KEY with your API Key.

To find your API Key, download WP Rocket from your account:

https://wp-rocket.me/account/

Open the license-data.php file and copy the value of WP_ROCKET_KEY.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.