
Hi folks,
Many TYPO3 sites are still deployed like in 2010: open the FTP client, upload the changed files over the live site, clear the cache, pray. With a Composer project this gets worse, because a composer install on the live folder replaces thousands of files in vendor/ while visitors are requesting pages. For some seconds, half of the classes are new and half are old. That is when the “Class not found” errors appear in the log, and nobody can reproduce them later.
The fix is old and boring, which is the best kind of fix: build every release in its own folder and switch a symlink when it is ready.
The folder layout
/var/www/example.org/
├── current -> releases/20261015-1530 # the web server's docroot is current/public
├── releases/
│ ├── 20261014-0910/
│ └── 20261015-1530/
└── shared/
├── public/fileadmin/
├── var/log/
└── config/system/credentials.phpEverything that belongs to the code lives in the release: vendor/, public/ with its _assets links, config/ from git and the release’s own var/cache. Everything that must survive a deployment lives in shared/ and is linked into each release:
public/fileadmin: editor uploads and processed images.var/log: you want one continuous log, not one per release.- The credentials file: database password and encryption key are not in git. On my own site they live in
config/system/credentials.php, whichadditional.phpincludes.
I do not share var/cache. The cache contains the compiled dependency injection container and other code caches, and they belong to exactly one version of the code. Sharing them between two releases is a reliable way to get very strange errors.
Step 1: Build the release once
Build in CI or on a build machine, never on the live folder:
composer install --no-dev --optimize-autoloader --no-interactionSince TYPO3 14.2, the public resources of extensions are published by an asset:publish command, which runs automatically during composer install. By default it creates symlinks in public/_assets. In my installation those links are relative (../../vendor/typo3/…), so they keep working when the whole release folder moves to the server. If your target does not like symlinks, 14.2 also added a copy strategy:
// config/system/additional.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['SystemResources']['filesystemPublishingType'] = 'mirror';Then upload the built folder with rsync into a new, timestamped release directory.
Step 2: Link the shared folders and prepare the release
This is the plain shell version I use when the server has SSH. It runs on the server, after the upload:
#!/usr/bin/env bash
set -euo pipefail
base=/var/www/example.org
release="$base/releases/$1" # e.g. 20261015-1530
typo3="php $release/vendor/bin/typo3"
# shared data into the new release
rm -rf "$release/public/fileadmin" "$release/var/log"
mkdir -p "$release/var"
ln -s "$base/shared/public/fileadmin" "$release/public/fileadmin"
ln -s "$base/shared/var/log" "$release/var/log"
ln -s "$base/shared/config/system/credentials.php" "$release/config/system/credentials.php"
# prepare the new release while the old one still serves traffic
export TYPO3_CONTEXT=Production
$typo3 extension:setup
$typo3 cache:warmup
# switch: create the new link next to the old one, then rename over it
ln -sfn "releases/$1" "$base/current.new"
mv -T "$base/current.new" "$base/current"
# frontend caches in the database may hold markup of the old release
$typo3 cache:flush --group pages
# keep the last five releases
ls -1d "$base"/releases/* | sort | head -n -5 | xargs -r rm -rfThe switch is the mv -T. Renaming a symlink over another one is a single filesystem operation on Linux, so a request sees either the old release or the new one, never half of each. A simple ln -sfn on current itself removes and recreates the link, which leaves a tiny gap. mv -T is GNU coreutils; on other systems check your mv.
Check the cache group names of your version with vendor/bin/typo3 cache:flush --help; if in doubt, a full cache:flush after the switch is fine too, it only costs some warm-up time.
Step 3: Database changes need two deployments
Here is the catch that the symlink does not solve: the database is shared between the old and the new release. When extension:setup adds a column, the old release keeps working, it just ignores the column. When a change renames or removes something the old code still reads, the old release breaks in the seconds before the switch.
So I split such changes. First deployment: add the new field, let the code write both. Second deployment, later: remove the old field. For upgrade wizards I am stricter: upgrade:run is part of a planned maintenance window with a database dump, not of a normal Tuesday deployment.
Step 4: The web server and the realpath cache
PHP caches resolved file paths, and OPcache caches compiled files by path. After the switch, PHP-FPM may still resolve current to the old release for a while. Two common remedies, use one or both:
# nginx: give PHP the resolved path of the release, not the symlink
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;and a graceful reload of PHP-FPM after the switch, if your hosting allows it. On shared hosting where you cannot do either, test how long the old release keeps answering, and keep at least that one release around.
Step 5: Rollback
Rollback is the same switch in the other direction:
cd /var/www/example.org
ln -sfn "releases/20261014-0910" current.new && mv -T current.new current
php current/vendor/bin/typo3 cache:flushThat takes seconds for the code. It does not roll back the database, which is one more reason for the two-step database changes above.
Or let Deployer do it
If you prefer a tool, Deployer has a TYPO3 recipe with exactly this layout. Its documented defaults share fileadmin, typo3temp/assets, var/lock, var/log, var/session and var/spool, and its deploy task runs extension:setup, a language update, cache flush and warmup before publishing. One tip: compare the TYPO3 commands of the recipe with vendor/bin/typo3 list of your installation. The recipe also lists typo3:install:fixfolderstructure, and the core CLI of my v14.3 installation has no install:fixfolderstructure command, so check what your setup provides before the first real deployment.
Whatever you choose, the idea is the same: build first, switch last, and never upload over a running site again. Cheers!