Skip to content

Deployer

If the project is deployed with Deployer, its deploy.php or deploy.yaml already knows the host, user, port and deploy path. Instead of copying them into a target, you can have ddev-sync read them.

targets:
production:
deployer:
host: web01.example # Deployer's alias; omit if there is only one
stage: production

deployer.host is the host’s alias as Deployer declares it, the name its host() call was given. That is often a hostname, but not necessarily: a project whose hosts are called production and staging has aliases that are not hostnames. From the alias ddev-sync takes the hostname (falling back to the alias when Deployer gives none), the user, the port, the deploy path and the layout. With exactly one host you can leave host out and write deployer: {}.

The layout is worked out from the same output: if Deployer’s current_path is its deploy_path plus current, the remote uses Deployer’s releases/current layout and the target gets layout: deployer automatically. Otherwise it is a plain one.

The block is strict, and there is no fallback. It is the only source for the host, user, port, path and layout. Setting any of host, ssh_alias, user, port, path or layout beside it is an error, not an override. The host inside the block is the alias, a different thing. If resolving fails, the run fails with the reason; ddev-sync never quietly substitutes a value from somewhere else. A stale fallback would be right on the machine where it was written and wrong on the next one, in a tool that replaces your local database.

Two things stay yours:

  • stage is still required. It is not a connection detail, and a host alias is not a stage name.
  • jump_host, jump_host_user and jump_host_port may be combined with the block. Deployer has no canonical field for a bastion, so there is nothing for the block to supply and nothing to conflict with.

deployer: cannot be combined with provider: docker.

The block is one of three ways of saying where to connect, alongside host and ssh_alias. Whichever the stronger target sets wins and the others are dropped, so a target can extend a literal one and switch to Deployer, or the reverse. Only a combination with the block is an error, whether within a single target or across files that define the same target name; host together with ssh_alias remains allowed, with the alias winning. One case is not symmetric: when the block wins, the base target’s user, port, path and layout are dropped along with its host, and a literal set by the target that extends it is rejected, because it contradicts the block.

ddev-sync runs dep config --format=json in the project’s web container, at the project root. It tries vendor/bin/dep first and then a dep on the container’s PATH.

Consequences:

  • The project must be running, because the command runs in the web container. The error for a stopped project can mislead: a stopped container makes docker exec exit with status 1, which looks exactly like a recipe that failed. The message carries the underlying error output, so read it before concluding that your deploy.php is broken. ddev sync targets never runs dep and contacts nothing remote, because it shows the block as you wrote it and not what it resolves to.
  • Deployer must be installed in the project. If neither vendor/bin/dep nor dep runs, ddev-sync stops and suggests ddev composer require --dev deployer/deployer.
  • The command runs once per invocation, even when several targets ask for different aliases.
  • If a host’s deploy_path or remote_user is missing from Deployer’s output, ddev-sync stops and says which one. An unset port means 22.

Deployer’s configuration holds no database credentials that ddev-sync reads. Those still come from the source you configure under database.remote_credentials, and the block does not change that.

Deployer often declares more than one host (production, staging). With a single host you may leave deployer.host out. With several, leaving it out is an error that lists the aliases Deployer declares. Name the one you want, once per target:

targets:
production:
deployer: { host: web01.example }
stage: production
staging:
deployer: { host: staging.example }
stage: staging

An alias Deployer does not know is an error that lists the ones it does.

When the project has a deploy.php or deploy.yaml, ddev sync init offers “Read it from Deployer” next to entering the connection by hand. With several hosts it lets you choose one.

If composer.json requires deployer/deployer but vendor/ is not there yet, init offers to run composer install --no-scripts in the web container for you. Declining ends the wizard with the reason and writes nothing.

Reading the connection from a recipe makes the sync depend on the recipe loading cleanly on your machine, and on the web container being up. If your deploy.php needs credentials or tooling that DDEV does not have, enter the connection by hand with layout: deployer instead; the result is the same and nothing is evaluated.

Syncing covers what a run does once the target resolves.