This is a beta release and is currently available to active Elite (and legacy Developer) license holders only. We encourage you to thoroughly test beta releases in controlled sandbox environments and do not recommend their use in production environments. Beta release functionality, features, and availability may be subject to change or removal at any time.
Introduction
You can use Composer to install and update Gravity Forms, Gravity SMTP, and related add-ons. Composer is a free third-party tool for dependency management in PHP that allows you to declare the packages you need, and it will manage them for you via your chosen CLI. With our Gravity Forms Composer Package, you can use Composer to install and update our Gravity Forms plugins, including Gravity SMTP and any of our suite Gravity Forms Add-Ons to which your active license key is entitled.
Who is this for?
Composer is a modern development approach to managing dependencies in PHP applications. In short, it’s a developer tool. If you are not a developer, then we would recommend installing and updating plugins using WordPress’s built-in plugin management system, including the auto-update functionality which Gravity Forms is designed to work with.
Pre-Requisites
- Requirements: PHP 8+
- Composer 2+ installed. Check with command
composer --version
. - A Command Line Interface (CLI) environment to execute commands.
- Read and write permission to the file structure of your WordPress directories.
Install using the Composer CLI
- Ensure you have a composer.json in your WordPress project. This file tells Composer what packages you want and where you wish to put them. If you do not have a composer.json file yet, run the command
composer init
and follow the prompts.
- Run the following command to set up authentication. If you want to install it globally, add the
--g
global flag.
composer config http-basic.composer.gravity.io LICENSE_KEY https://SITE_URL
Replace LICENSE_KEY
with your plugin license key string and SITE_URL
with your url you want to activate.
- Add the Gravity Composer Package Repository by running the following command. You may be prompted to allow
composer/installers
, typeyes
, and press enter.
composer config repositories.gravity '{"type": "composer", "url": "https://composer.gravity.io"}'
- Install the required plugins or add-ons your license key has access to. Use
gravity/slug
to get the plugin or add-on.
For Gravity Forms usegravity/gravityforms
For Gravity SMTP usegravity/gravitysmtp
composer require gravity/gravityforms gravity/gravitysmtp
Refer to this article for a comprehensive list of the available add-ons.
Install manually using Composer
If for any reason the CLI method is not working, you can configure everything manually.
- Ensure you have a composer.json at the root of your WordPress project. If not, create one and enter this info:
{
"name": "org/package",
"authors": [
{
"name": "Your Name",
"email": "[email protected]"
}
],
"require": {},
}
- Set up Authentication by creating an auth.json file in the root of your WordPress project and entering this info:
{
"http-basic": {
"composer.gravity.io": {
"username": "YOUR_LICENSE_KEY",
"password": "https://YOUR_SITE_URL"
}
}
}
- Add the Gravity Composer Package Repository to the
composer.json
file.
{
"name": "org/package",
"authors": [
{
"name": "Your Name",
"email": "[email protected]"
}
],
"require": {},
+ "repositories": {
+ "gravity": {
+ "type": "composer",
+ "url": "https://composer.gravity.io"
+ }
+ }
}
- Add the plugins you wish to install to
composer.json
manually in therequire: {}
area of the file.
"require": {
"gravity/gravityforms": "*",
"gravity/gravitysmtp": "*"
}
- Run
composer install
Managing Gravity Plugin Versions using Composer
Refer to this user guide by the Composer team for more information about managing versions using Composer.
Managing Individual Plugins
You can use the composer require
command to install as new (or upgrade the exsiting installation) an individual plugin.
This option will install and/or update a single add-on defined by {slug}:
composer require gravity/{slug}
This option will install and/or update a single add-on defined by {slug} to a particular version, specified by {version}:
composer require gravity/{slug}:{version}
Refer to this guide for a list of the available add-ons and their slugs.
Examples:
composer require gravity/gravityforms
— would install the latest version of Gravity Forms to the location defined in your composer.json filecomposer require gravity/gravityforms:2.9.5
— would install Gravity Forms version 2.9.5 to the location defined in your composer.json file.
composer require gravity/gravityforms:2.9
— would install the latest version that begins with 2.9. This acts as like a pattern match of 2.9.*
composer require gravity/gravityforms:2.9.0
— would install the exact Gravity Forms version, 2.9.0
Customize the Installation Path
All our packages are tagged with the type wordpress-plugin
and will default install into the wp-content/plugins
directory. But if you need to change the path, you can add the following code to your composer.json and update it to the desired relative path to your composer.json file.
{
"name": "org/package",
"authors":
[
{
"name": "Your Name",
"email": "[email protected]"
}
],
"require": {},
"repositories": {
"gravity": {
"type": "composer",
"url": "https://composer.gravity.io"
}
},
+ "extra":{
+ "installer-paths": {
+ "wp-content/plugins/{$name}":
+ ["type:wordpress-plugin"]
+ }
+ }
}