2019-07-02 08:05:15 +03:00
# CLI Usage
After [installation ](installation.md ) of Deployer you will have the ability to run the `dep` command from your terminal.
2021-04-03 11:44:40 -04:00
To get list of all available tasks run the `dep` command. You can run it from any subdirectories of you project;
Deployer will automatically find project root dir.
```bash
2019-07-02 08:05:15 +03:00
Deployer
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-f, --file[=FILE] Specify Deployer file
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
init Initialize deployer system in your project
list Lists commands
run Run any arbitrary command on hosts
self-update Updates deployer.phar to the latest version
ssh Connect to host through ssh
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
The best way to configure your `deploy.php` is to automatically deploy to staging on this command:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep deploy
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
This is so somebody can't accidentally deploy to production (for production deployment, the `dep deploy production` command explicitly lists the required production stage).
You need info about available options and usage use the `help` command:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
$ dep help deploy
Usage:
deploy [options] [--] [< stage > ]
Arguments:
stage Stage or hostname
Options:
-p, --parallel Run tasks in parallel
-l, --limit=LIMIT How many host to run in parallel?
--no-hooks Run task without after/before hooks
--log=LOG Log to file
--roles=ROLES Roles to deploy
--hosts=HOSTS Host to deploy, comma separated, supports ranges [:]
-o, --option=OPTION Sets configuration option (multiple values allowed)
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-f, --file[=FILE] Specify Deployer file
--tag[=TAG] Tag to deploy
--revision[=REVISION] Revision to deploy
--branch[=BRANCH] Branch to deploy
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
2021-04-03 11:44:40 -04:00
2019-07-02 08:05:15 +03:00
Help:
Deploy your project
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
### Overriding configuration options
For example, if your _deploy.php_ file contains this configuration:
2021-04-03 11:44:40 -04:00
```php
2019-07-02 08:05:15 +03:00
set('ssh_multiplexing', false);
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
And you want to enable [ssh multiplexing ](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing ) without modifying the file, you can pass the `-o` option to the `dep` command:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep deploy -o ssh_multiplexing=true
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
To override multiple config options, you can pass multiple `-o` args:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep deploy -o ssh_multiplexing=true -o branch=master
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
### Running arbitrary commands
2021-04-03 11:44:40 -04:00
2019-07-02 08:05:15 +03:00
Deployer comes with a command to run any valid command on you server without modifying _deploy.php_
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep run 'ls -la'
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
To specify the hosts this command has the corresponding options:
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
--stage=STAGE Stage to deploy
--roles=ROLES Roles to deploy
--hosts=HOSTS Host to deploy, comma separated, supports ranges [:]
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
### Getting help
You can get more info about any commands by using the help command:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep help [command]
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
### Autocomplete
Deployer comes with an autocomplete script for bash/zsh/fish, so you don't need to remember all the tasks and options.
To install it run following command:
2021-04-03 11:44:40 -04:00
```bash
2019-07-02 08:05:15 +03:00
dep autocomplete
2021-04-03 11:44:40 -04:00
```
2019-07-02 08:05:15 +03:00
And follow instructions.
2021-09-07 10:03:01 +02:00
### Local root directory
By default `runLocally()` commands are executed relative to the recipe file directory. This can be overridden globally by setting an environment variable:
```bash
DEPLOYER_ROOT=. dep taskname`
```
Alternatively the root directory can be overridden per command via the cwd configuration.
```php
runLocally('ls', ['cwd' => '/root/directory']);
```