Deploying
The deploy command
npm ci && npm run build # or pass --assets to deploy
composer install --no-dev --optimize-autoloader
php bin/console deploy # in DDEV: ddev console deploydeploy runs its steps in order: optimize the autoloader, rebuild var/cache (routes, posts, translations, templates, the Vite manifest), publish post files, refresh the web server's Opcache, and purge the CDN when CDN caching is on.
Run it after every change: code, templates, content or configuration. In production, changes aren't picked up until then.
Options
| Option | |
|---|---|
--list-steps | show the steps in order and exit |
--skip=a,b | leave steps out |
--assets | run npm run build first |
--opcache=cachetool|reload|none | how to refresh Opcache (default: APP_OPCACHE, else cachetool) |
--fcgi=… | PHP-FPM socket or host:port, for cachetool (default: APP_FPM_SOCKET, else /run/php-fpm.sock) |
--cachetool=… | the cachetool binary (default: APP_CACHETOOL, else cachetool) |
--reload-cmd=… | the command for --opcache=reload (default: APP_OPCACHE_RELOAD_CMD) |
--composer=… | the Composer binary |
--no-dev | exclude require-dev packages from the autoloader |
--skip-composer | same as --skip=composer |
--skip-opcache | same as --opcache=none |
Set the Opcache variables once per server in its .env, and a plain php bin/console deploy does the right thing everywhere.
After deploying, locally
deploy makes the Composer autoloader authoritative: new classes in src/ aren't found until the next deploy. When you go back to development:
php bin/console cache:clearIt empties the caches, rebuilds the normal autoloader with composer dump-autoload (only when a deploy left it authoritative; --composer=<path> if Composer isn't on your PATH), and removes the post and page files published to public/media/, which would otherwise shadow the originals in content/.
Production checklist
[ ] Keep
var/images/between deploys (encoded images are reused from there)[ ]
MAILER_DSN,MAILER_FROMandCONTACT_TOfor the contact form (send yourself a test message)[ ]
.env(or real environment variables) withAPP_URL,APP_SECRET;APP_DEBUGunset[ ] PHP 8.4 with
intl,mbstring,opcache;display_errors=Off,log_errors=On[ ] web server root at
public/, everything else routed topublic/index.php[ ]
var/cachewritable by the deploy user and readable by PHP;var/logwritable by PHP[ ] Behind a CDN:
CDN_CACHE=1andCDN_PURGEwith its credentials (CDN caching), and the CDN in your privacy policy[ ]
LOG_ALERT_TOto hear about errors by email (Logging), and the web server's access log turned off or without IP addresses (Access logs)[ ] the Opcache mode for this server (
APP_OPCACHE), see Servers & Opcache[ ] HTTPS, and
APP_TRUSTED_PROXIESif behind a proxy or load balancer