Magento Cloud CLI reference

The Magento Cloud CLI is a cloud-specific version of the Magento CLI we provide supporting commands including Magento management and Git interactions. You can install and use these commands for all Starter environments and Pro Integration environments. You cannot use these commands on Pro plan Staging and Production environments.

This reference lists all available commands, and a list of commonly used commands, for Magento Commerce (Cloud). You can also use Magento CLI commands as needed, using bin/magento for entering commands.

You will install the Magento Cloud CLI on your local when setting up your local environment for development.

You must install the Magento Cloud CLI to your local workspace to issue commands. For details, see:

The following Magento Cloud CLI commands can be run from any directory and run best from a project directory. When run from a project directory, you can omit the -p <project ID> parameter. These commands are meant to be used to manage Integration environments.

You may notice these commands are similar to Git commands. The magento-cloud Git commands directly connect with Magento Git, the Magento ECE project, with additional features. For example, when you push a Git branch, it is not activated until you access GitHub. The Magento CLI command includes activation.

All listed commands include only the required information and options. These commands may include additional options. To see all options and help, append --help with any magento-cloud command .

git commit --allow-empty -m "redeploy" && git push <branch name>
Push an empty commit to force a redeployment. Some actions, like adding a user for example, don’t result in deployment.
magento-cloud login
Log in to the project.
magento-cloud project:get <project ID> <directory> -e <environment ID>
Clone a project to a directory. To clone the master environment, omit -e <environment ID>.
magento-cloud environment:list -p <project ID>
List the environments in the current project (that is, the project that corresponds to the directory in which you run the command).

magento-cloud environment:list displays environment hierarchies whereas git branch does not. If you have any nested environments, use magento-cloud environment:list.

magento-cloud environment:branch <name> <parent branch>
Create a new branch; the environment has both a name and an ID.

The environment name is different from the environment ID only if you use spaces or capital letters in the environment name. An environment ID consists of all lowercase letters, numbers, and allowed symbols. Capital letters in an environment name are converted to lowercase in the ID; spaces in an environment name are converted to dashes.

An environment name cannot include characters reserved for your Linux shell or for regular expressions. Forbidden characters include curly braces ({ }), parentheses, asterisk (*), angle brackets (< >), ampersand (&), percent (%), and other characters.

magento-cloud environment:checkout <environment ID>
Check out an existing environment.
magento-cloud environment:merge -p <project ID> -e <environment ID>
Merge changes in this environment with its parent.
magento-cloud environment:synchronize -p <project ID> -e <environment ID> {code|data}
Synchronize (that is, git pull) code and/or data from the parent to this environment.
magento-cloud variable:list
List variables in this environment.
magento-cloud variable:set <name> <value>
Set a value for an environment variable in this environment.

Display all commands

The magento-cloud list displays all available commands.

Help for a command

You can preface or append any command with help or --help to see more information on how to use that command.

$ magento-cloud domain:add --help
Command: domain:add
Description: Add a new domain to the project

Usage:
 domain:add [--project[="..."]] [--cert="..."] [--key="..."] [--chain="..."] [name]

Arguments:
 name                  The name of the domain

Options:
 --project             The project ID
 --cert                The path to the certificate file for this domain.
 --key                 The path to the private key file for the provided certificate.
 --chain               The path to the certificate chain file or files for the provided certificate. (multiple values allowed)
 	 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages
 --version (-V)        Display this application version
 --yes (-y)            Answer "yes" to all prompts
 --no (-n)             Answer "no" to all prompts
 --shell (-s)          Launch the shell

List of Magento CLI commands

The following table provides an extensive list of Magento CLI commands for ECE accessed with magento-cloud To see a full list of commands, enter magento-cloud list. The listed commands are for Magento Cloud CLI version 1.11.1 and later.

The following table lists general commands.

Command Description
clear-cache Clears the cache for only the CLI.
docs Provides a link for documentation.
help Displays help information for the command.
list Displays a list of all available commands in the Magento Cloud CLI.
multi Executes a command on multiple projects entered as a command separated list for the -p parameter.
web Opens a web UI based on the parameters you enter.

The following table lists all commands for interacting with your environments and projects.

Command Description
activity:list (activities) Gets a list of activities for an environment
activities:log Displays the log for an environment activity
app:config-get Views the configuration of an app
app:list (apps) Gets a list of all apps in the local repository
auth-info Display yourt account information
auth:login (login) Log in to the Magento Cloud CLI
auth:logout (logout) Log out of Magento Cloud CLI
certificate:add Adds an SSL certificate to the project
certificate:delete Deletes a certificate from the project
certificate:get View a certificate added to the project
certificate:list (certificates) Lists project certificates
clean Removes old project builds. When using local:build in a separate location from your code, use this command to clear those builds. By default, your latest five builds are not deleted.
db:dump Creates a local dump of the remote database data. You can push the dump to another remote database. For example, you could pull data from the Production environment (products, catalogs, etc) and push it into Staging for testing.
db:size Estimates the disk usage of the database.
db:sql (sql) Opens an SQL console on the remote database. You can view tables and dump data from a local to the remote database. For example, you could push a data dump from Production into Staging for testing.
domain:add Adds a new domain to the project
domain:delete Deletes a domain from the project
domain:get Shows detailed information for a domain including the project ID, hostname, and so on
domain:list (domains) Gets a list of all domains
domain:update Updates data for a domain
environment:activate Activates an environment
environment:branch (branch) Branches an environment, or creates a Git branch
environment:checkout (checkout) Checks out an environment, or Git branch
environment:delete Deletes an environment
environment:http-access (httpaccess) Updates HTTP access settings for an environment
environment:info Reads or sets properties for an environment
environment:list (environments) Gets a list of environments
environment:logs (log) Reads an environment's logs
environment:merge (merge) Merges an environment
environment:push (push) Pushes code to an environment
environment:relationships (relationships) Displays an environment's relationships
environment:ssh (ssh) Opens an SSH session to the current environment
environment:synchronize (sync) Synchronizes an environment's code and or data from its parent
environment:url (url) Gets the public URLs of an environment
integration:add Add an integration to the project
integration:delete Deletes an integration from a project
integration:get Shows details for an integration
integration:list (integrations) Views project integration(s)
integration:update Updates an integration
local:build (build)

Builds the current project locally strictly to test the build without the full patch and commit process. This command allows you to build locally without patches just to check the build. We recommend you run this command separately in a different location. You should not commit the files from this build to Git.

You should only use this command to test a local build, not to build and deploy.

local:dir (dir) Locates the root directory. Use the command with a subdirectory argument of local, web, or shared to locate those directories.
project:get (get) Clones a project locally
project:info Reads or sets properties for a project
project:list (projects) Gets a list of all active projects
project:set-remote Set the remote project for the current Git repository
project:variable:delete Delete a variable from a project
project:variable:get (project-variables, pvget) View variable(s) for a project
project:variable:set (pvset) Set a variable for a project
route:get View a resolved route
route:list (routes) List all routes for an environment
self:install Installs or updates CLI configuration files
self:update (self-update) Updates the CLI tot he latest version
snapshot:create (backup) Makes a snapshot of an environment
snapshot:list (snapshots) List available snapshots of an environment
snapshot:restore Restores an environment snapshot
ssh-key:add Adds a new SSH key
ssh-key:delete Deletes an SSH key
ssh-key:list (ssh-keys) Gets a list of SSH keys in your account
tunnel:close Closes SSH tunnels
tunnel:info Views relationships info for SSH tunnels
tunnel:list (tunnels) Lists SSH tunnels
tunnel:open Open SSH tunnels to an app's relationship
user:add Adds a user to the project
user:delete Deletes a user from the project
user:list (users) Lists users for the project
user:role View to change a user's role
variable:delete Deletes an environment variable for a specific environment/Git branch
variable:get (variables, vget) Views variable(s) for a specific environment/Git branch
variable:set (vset) Sets an environment variable for a specific environment/Git branch

Upgrade Magento Cloud CLI

When you login to the Magento Cloud CLI, it checks for available updates. You can enter y for yes to upgrade. After upgrading, you can login and use the magento-cloud list command to see a list of all commands.