Skip to main content
Version: 7.x


To define a new host use the host() function. Deployer keeps a list of all defined hosts in the Deployer::get()->hosts collection.


Each host contains it's own configuration key-value pairs. The host() call defines two important configs: alias and hostname.

  • hostname - used when connecting to remote host.
  • alias - used as a key in Deployer::get()->hosts collection.
task('test', function () {
writeln('The {{alias}} is {{hostname}}');
$ dep test
[] The is

We can override hostname via set() method:

->set('hostname', '');

The hostname will be used for the ssh connection, but the host will be referred to by it's alias when running Deployer.

$ dep test
[] The is

Another important ssh connection parameter is remote_user.

->set('hostname', '');
->set('remote_user', 'deployer');

Now Deployer will connect using something like ssh to establishing connection.

Also, Deployer's Host class has special setter methods (for better IDE autocompletion).

Config file

It is a good practice to keep connection parameters out of deploy.php file, as they can change depending on where the deploy is executed from. Only specify hostname and remote_user and other keep in ~/.ssh/config:

Host *
IdentityFile ~/.ssh/id_rsa

Host config

setHostnameThe hostname
setRemoteUserThe remote_user
setPortThe port
setConfigFileFor example, ~/.ssh/config.
setIdentityFileFor example, ~/.ssh/id_rsa.
setForwardAgentDefault: true.
setSshMultiplexingDefault: true.
setShellDefault: bash -ls.
setDeployPathFor example, ~/myapp.
setLabelsKey-value pairs for host selector.
setSshArgumentsFor example, ['-o UserKnownHostsFile=/dev/null']

Multiple hosts

You can pass multiple hosts to the host function:

host('', '', ...)

Host ranges

If you have a lot of hosts following similar patterns, you can describe them like this rather than listing each hostname:


For numeric patterns, leading zeros can be included or removed, as desired. Ranges are inclusive.

You can also define alphabetic ranges:



The localhost() function defines a special local host. Deployer will not connect to this host, but will execute commands locally instead.

localhost(); // Alias and hostname will be "localhost".
localhost('ci'); // Alias is "ci", hostname is "localhost".

YAML Inventory

You can use the import() function to keep host definitions in a separate file. For example, inventory.yaml.

remote_user: deployer
remote_user: deployer

Support Deployer โค๏ธ

Hello, my name is Anton Medvedev. I'm the creator of the Deployer. I maintain this open source project in my spare time. Supporters on GitHub give me extra motivation to work on the project.

Consider supporting Deployer via GitHub Sponsors.