Composer is a dependency manager for PHP, which you can use for your WordPress websites. This document will show you how to manage Astra Pro on your projects using Composer.
With Composer, you can add all of your standard themes and plugins to a new WordPress site from one place. Also, you can keep your websites updated the same way.
Using Astra Pro With Composer
You can use Composer to upgrade or downgrade Astra Pro. Before using Composer, you’ll need to have the Astra Pro plugin installed and your license activated. Thus, you’ll need to do this manually on any new website.
Follow these steps to prepare your new website before using Composer:
Step 1 – Install and activate the Astra Pro plugin. If you’re not sure how to do this, you can check out this document;
Step 2 – Next, copy your Astra Pro license from the Store, and activate the license on your website. Further, you can find more details about activating the license in this document.
Activating the plugin license on your new website will register the website URL with our Store. Now you can configure your Composer.json file and manage Astra Pro with Composer further on.
Configure The Composer.json File
The composer.json file is necessary for Composer to work on your website. To manage the Astra Pro with Composer, you’ll need to configure the composer.json file and add Astra Pro-related code.
Here, we assume that you already have the file in your website’s root directory. Also, we are assuming that you have set your project. Check this article if you need help installing Composer, adding composer.json file, or setting up the project.
Let’s get started.
Code Example
You can check the example of the entire code:
{ "name": "example/example", "type": "project", "description": "Project description", "require": { "brainstormforce/astra-addon": "^3.0" }, "extra": { "installer-paths": { "wp-content/plugins/{$name}/": ["type:wordpress-plugin"] } }, "repositories": [ { "type": "package", "package": { "name": "brainstormforce/astra-addon", "version": "3.6.3", "type": "wordpress-plugin", "dist": { "type": "zip", "url": "https://support.brainstormforce.com/wp-json/bsf-products/v1/download/astra-addon/?purchase_key={PURCHASE_KEY}&site_url={SITE_URL}" }, "require": { "composer/installers": "^1.11" } } } ] }
Further below, we’ll show you how to make this work.
Add Astra Pro Package And Version Constraints
"require": { "brainstormforce/astra-addon": "^3.0" },
You need to add the following line to your composer.json file under the “require” key. This will tell Composer to add the Astra Pro package to the list of packages your project depends on.
Also, this will set the Astra Pro plugin version constraints to any stable version above 3.0.0.
Repositories Arrey
"repositories": [ { "type": "package", "package": { … } } } ]
Next, you need to register Astra Pro Package Repository in your composer.json file. To do this, you must first edit the Astra Pro Package object.
repositories: Repository Arrey containing Astra Pro Package object
Element | Description | Type |
package | Package description for Astra Pro version which is requested | package element |
Astra Pro Package Object
The “package” object contains data on the Astra Pro package you are requesting. Here, you need to modify the version string for each update. Thus, to upgrade Astra Pro with Composer, add a version number higher than the one you have currently installed. Similarly, to downgrade Astra Pro, add an earlier plugin version number.
"package": { "name": "brainstormforce/astra-addon", "version": "3.6.3", "type": "wordpress-plugin", "dist": { "type": "zip", "url": "https://support.brainstormforce.com/wp-json/bsf-products/v1/download/astra-addon/?purchase_key={PURCHASE_KEY}&site_url={SITE_URL}" }, "require": { "composer/installers": "^1.11" } }
package: Astra Pro Package Description Object
Element | Description | Type | Notes |
version | The Astra Pro version which is requested | string | You need to specify the exact version in format “X.X.X” (e.g. “3.6.3”) for each update. |
dist | The packaged version of Astra Pro stable version files | Package data object | |
url | Download link with authentication parameters | string | url element |
Also, you need to update the url parameters by adding your Astra Pro license key and a domain of the website on which you’re updating the plugin.
url: URL parameters
Parameter | Description | Type | Required | Notes |
PURCHASE_KEY | The Astra Pro key | string | Required | The key can be acquired from our Store at Account > Licenses |
SITE_URL | The domain of your website (without HTTPS) | string | Required | Valid format is: “example.com” (not “https://example.com”) |
URL example:
https://support.brainstormforce.com/wp-json/bsf-products/v1/download/astra-addon/?purchase_key=fdsi3h3iu4n22l344n4l2&site_url=example.com
Install or Update Astra Pro With Composer
Now that your composer.json is configured, you are ready to update or install Astra Pro on your website. You can install or update Astra Pro by running the following command in Composer:
composer update