Sharing Your TYPO3 Project with `ddev share` (Video)
ddev share lets you share your running local project with anybody in the world. It can be used for collaboration or demonstration to clients. All the details are in the DDEV docs.
TYPO3 projects sometimes provide a special challenge for ddev share if they have the full URL specified in the config/sites/*/config.yaml base, like base: https://typo3demo.ddev.site. When you ddev share and get an arbitrary URL from Cloudflared or ngrok, TYPO3 refuses to show the site because it’s not the specified URL.
This isn’t a problem at all if the base element doesn’t include the URL. For example, with base: /camino on a project like the DDEV TYPO3 quickstart, everything works fine out of the box, there’s nothing to do. The share URL with /camino will work fine.
But we can solve this problem with DDEV’s pre-share hooks, see below
Watch the Video
What You’ll See
- Basic
ddev sharewithout URL inbase - Problem
ddev sharewith URL - Fix with
pre-sharehooks
The Fix: pre-share and post-share Hooks
DDEV exports the tunnel URL as $DDEV_SHARE_URL when you run ddev share. You can use pre-share and post-share hooks to temporarily disable the base: setting for the duration of the share session, and restore it afterward:
# .ddev/config.yaml
hooks:
pre-share:
- exec: |
for f in config/sites/*/config.yaml; do
cp "$f" "$f.pre-share-backup"
newbase=$(yq '.base' "$f" | sed -E 's#^https?://[^/]+##')
[ -z "$newbase" ] && newbase="/"
yq -i ".base = \"$newbase\"" "$f"
done
typo3 cache:flush
post-share:
- exec: |
for f in config/sites/*/config.yaml.pre-share-backup; do
mv "$f" "${f%.pre-share-backup}"
done
typo3 cache:flush
This strategy checks your config.yaml, temporarily updates the base to use only the required / or other URL, and then does a typo3 cache:flush.
At the end of the share, the original config.yaml is restored by the post-share hook.
Of course your project should be under Git source control in case anything should go wrong, or you never exit the share, etc.
Trusted Host Patterns
DDEV already automatically adds the trustedHostsPattern to the additional.php which is used only running with DDEV. This allows the project to work on a shared URL.
return [
# ...
'SYS' => [
'trustedHostsPattern' => '.*.*',
'devIPmask' => '*',
'displayErrors' => 1,
],
];
Example project: rfay/typo3demo
A pre-built example project based on the TYPO3 docs and DDEV quickstart is at rfay/typo3demo, and has post-start hooks for composer: install and pre-share hooks as described here.
Learn More
For background on the ddev share provider system, including using either ngrok or the free Cloudflare Tunnel option and how $DDEV_SHARE_URL hooks work for other CMSs, see the announcement blog and the docs on ddev share.
If you have questions, reach out in any of the support channels.
Follow our blog, Bluesky, LinkedIn, Mastodon, and join us on Discord. Sign up for the monthly newsletter.
This article was edited and refined with assistance from Claude Code.