CLI (Command line interface)
The CLI is the official tool to use and manage your Platform.sh projects directly from your terminal. Anything you can do within the management console can be done with the CLI.
Behinds the scenes it uses both the Git interface and our REST API. The source code of the CLI is hosted on GitHub.
Find detailed information on setting up a local development environment.
Install the CLI using this command:
curl -fsS https://platform.sh/cli/installer | php
You can find the system requirements and more information in the installation instructions on GitHub.
The Platform.sh CLI will authenticate you with Platform.sh and show your projects. Run this command to start:
You will be asked to log in via a browser.
When you are logged in, a list of your projects appears, along with some tips for getting started.
Your command-line tools are now ready to use with Platform.sh.
For further details, consult the Platform.sh CLI docs on Authentication.
The CLI uses the Platform.sh API to trigger commands (such as branch, merge) on your projects.
It’s also very useful when you work locally since it can simulate a local build of your codebase as if you were pushing a change to Platform.sh.
Once you have the CLI installed, run
platform list to see all of the available commands.
You can preface any command with
help to see more information on how to use that command.
$ platform help domain:add 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
Some CLI commands (especially many within the
environment namespace) have some overlap with Git commands. Generally, they offer more options than the Git commands alone. For example,
platform push offers options such as
--activate (to active an environment before pushing) and
--no-wait (so you can continue working without waiting for the push to complete).
For all of them, you don’t need to configure a Git remote. It is enough to have a project ID.
An example of how this affects commands is that when you run
platform merge, it doesn’t affect your local codebase. You don’t even need the code locally. The code is only merged between environments remotely.
Additional settings to control the operation of the Platform.sh CLI can be managed in the configuration file (
.platform/local/project.yaml) or environment variables. See the
README for the CLI for details.
When your shell’s working directory is inside a local checkout of your project repository, the CLI will automatically detect your project ID and environment so you don’t need to list them as parameters each time.
In your home directory, for example, you need to provide the project ID as an argument each time:
$ platform project:info --project=acdefghijkl --environment=staging
You can instead get the same result with just:
$ cd myproject $ platform project:info
You can also set a preferred project ID with the environment variables
export PLATFORM_PROJECT=acdefghijkl; export PLATFORM_BRANCH=staging; platform project:info
Once installed, the
platform CLI tool provides tab auto-completion for commands, options, and even some values (your projects, valid regions).
Your system must include the
bash-completion package or equivalent. This is not available by default on macOS, but can be installed via
brew. Check your home directory and ensure that the file
~/.platformsh/autocompletion.sh is being included by your shell.
platform self:install will attempt a reinstall of this utility if it’s needed.
There are multiple ways to install the CLI on Windows 10. Platform.sh recommends using Bash for Windows (Windows Subsystem for Linux).
You can install Bash to use the CLI on a Windows 10, 64-bit machine. The Windows 10 Anniversary Update is needed to support Git.
To install Bash on Windows 10 Anniversary Edition you need to:
- Activate the Developer Mode in “Update & Security” in Windows Settings. This will prompt you to restart your computer.
- Activate the “Windows Subsystem for Linux (Beta)”, under “Turn Windows features on or off” in the Programs and Features section of the Control Panel. Once again, you will need to restart your computer.
- In the Start Menu, search for the program “bash.exe”, which will prompt you to install it from the Windows Store.
Bash is now installed.
You can read more on WindowsCentral.
Upon starting Bash, you will be asked to choose a username. According to the article, it doesn’t have to be the same as your current username. However, if the username don’t exist, the Linux system might not be able to create the Linux directory (depending on your permissions level). It is therefore recommended you use the same username for Linux as your Windows machine (provided your Windows user name isn’t “Admin”, as that will not be allowed).
Once Bash for Windows is installed, you can install the Platform.sh CLI with the same command as above:
curl -fsS https://platform.sh/cli/installer | php