Skip to content

Deploy steps ​

bin/console deploy runs named steps in order. Your site can add its own: a command that builds files the site serves, a cache to warm, a notification to send.

Built-in steps ​

sh
ddev console deploy --list-steps
StepWhat it does
assetsonly with --assets: npm run build
checkbin/console check (Checking first): an error stops the deploy
composercomposer dump-autoload --optimize --classmap-authoritative
cachestart the new cache, aside, in var/deploy/next/cache/
routescompile the router
blogcompile the posts and publish their files for public/media/blog/ (images without metadata, plus their responsive versions)
pagescompile the content pages, check that no route hides one, publish their files for public/media/pages/
collectionscompile the data collections, publish their item folders' files for public/media/collections/
embedsdownload the posters and titles of ::youtube / ::vimeo videos to public/media/embeds/ (a failed download is a warning)
translationscompile the translation catalogues
templatescompile every Twig template
vitecache the Vite manifest; without it the deploy stops (every page needs it), unless the site has no vite.config.js
switchmove the new cache and files in place of the live ones, keeping those in var/deploy/prev/ (Build first, switch last)
opcacherefresh the web server's Opcache (Servers & Opcache)
cdnpurge the CDN, when CDN caching is on and CDN_PURGE is set

Adding a step ​

In config/bootstrap.php:

php
// A console command (from src/Command/)
$app->addDeployStep('audio', 'app:build-audio', 'Encode the sound files');

// A closure
$app->addDeployStep('stats', function (Kernel $app, SymfonyStyle $io): ?bool {
    $io->writeln(sprintf(' ✔ %d posts', $app->posts()->count()));

    return true; // false stops the deploy
}, 'Print stats', after: 'blog');
php
$app->addDeployStep(
    string $name,
    \Closure|string $step,     // closure, or a console command name
    string $description = '',
    ?string $before = null,    // insert before this step…
    ?string $after = null,     // …or after this one
);

Without before or after, the step runs just before switch: what it writes into the new cache goes live with the rest, and a failure leaves the live site as it was.

How steps run ​

  • a closure receives the kernel and the console output; returning false stops the deploy with exit code 1
  • a command step runs the command; a non-zero exit code stops the deploy
  • app steps run with the same production-mode kernel as the rest of the deploy
  • the kernel builds the new cache: $app->cacheDir is var/deploy/next/cache/ until switch, so a step writes there and its files go live with the rest. A step after switch sees the live site (a notification, a warm-up request); don't write into the cache from there
  • the cache step guarantees the new cache folder exists, so later steps can write into it

Skipping steps ​

sh
ddev console deploy --skip=composer,opcache

An unknown step name in --skip, or a before/after pointing to an unknown step, is an error before anything changes.

TinyTank documentation