Skip to content

Commit b4be574

Browse files
committed
TYPO3 and WP examples
1 parent d0f48a1 commit b4be574

File tree

1 file changed

+52
-19
lines changed

1 file changed

+52
-19
lines changed

src/content/blog/share-providers.md

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "New `ddev share` Provider System Brings Free Sharing Options"
3-
pubDate: 2026-01-22
4-
summary: "DDEV v1.25.0 introduces a flexible provider system for `ddev share`, bringing free Cloudflare tunnel support, automation capabilities, and extensibility for custom sharing solutions."
2+
title: "New `ddev share` Provider System: Cloudflare tunnel with no login or token"
3+
pubDate: 2026-02-10
4+
summary: "DDEV v1.25.0 introduces a flexible provider system for `ddev share`, adding free Cloudflare tunnel support, automation capabilities, and extensibility for custom sharing solutions."
55
author: Randy Fay
66
#featureImage:
77
# src: /img/blog/2026/01/ddev-share-providers.png
@@ -12,65 +12,98 @@ categories:
1212
- DevOps
1313
---
1414

15-
Sharing your local development environment with clients, colleagues, or testing services has always been a valuable DDEV feature. DDEV v1.25.0 makes this easier and more flexible than ever with a complete redesign of `ddev share`. The biggest news? You can now share your projects for free using Cloudflare Tunnel—no account signup or token setup required.
15+
Sharing your local development environment with clients, colleagues, or testing services has always been a valuable DDEV feature. DDEV v1.25.0 makes this easier and more flexible than ever with a complete redesign of `ddev share`. The biggest news is that you can now share your projects for free using Cloudflare Tunnel—no account signup or token setup required.
1616

1717
## What Changed in `ddev share`
1818

1919
Previous versions of DDEV relied exclusively on ngrok for sharing. While ngrok remains a solid choice with advanced features, v1.25.0 introduces a modular provider system that gives you options. DDEV now ships with two built-in providers:
2020

21-
- **ngrok**: The traditional option (requires account and authtoken)
21+
- **ngrok**: The traditional option (requires free account and authtoken)
2222
- **cloudflared**: A new, cost-free option using Cloudflare Tunnel (requires no account or token)
2323

24-
You can select providers via command flags, project configuration, or global defaults—whichever fits your workflow. Existing projects using ngrok continue working unchanged; ngrok remains the default provider.
24+
You can select providers via command flags, project configuration, or global defaults. Existing projects using ngrok continue working unchanged, and ngrok remains the default provider.
2525

2626
## Free Sharing with Cloudflare Tunnel
2727

28-
Cloudflare Tunnel provides production-grade infrastructure for sharing your local environments at zero cost. After [installing the client](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/create-local-tunnel/), getting started is as simple as:
28+
Cloudflare Tunnel provides production-grade infrastructure for sharing your local environments at zero cost. After [installing the `cloudflared` client](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/create-local-tunnel/), getting started is:
2929

3030
```bash
31-
ddev share -provider cloudflared
31+
ddev share --provider=cloudflared
3232
```
3333

3434
No account creation, no authentication setup, no subscription tiers—just immediate access to share your work. This removes barriers for individual developers and teams who need occasional sharing without the overhead of managing service accounts.
3535

36-
When should you use cloudflared vs ngrok? Use cloudflared for quick, free sharing during development and testing. Choose ngrok if you need stable subdomains, custom domains, or advanced features like IP allowlisting and OAuth protection.
36+
When should you use cloudflared vs ngrok? Use cloudflared for quick, free sharing during development and testing. Choose ngrok if you need stable subdomains, custom domains, or advanced features like IP allowlisting and OAuth protection. (However, if you control a domain registered at Cloudflare you can use that for stable domains. This will be covered in a future blog.)
3737

3838
## Configuration Flexibility
3939

4040
You can set your preferred provider at multiple levels:
4141

4242
```bash
4343
# Use a specific provider for this session
44-
ddev share -provider cloudflared
44+
ddev share --provider=cloudflared
4545

4646
# Set default provider for the current project
47-
ddev config --share-provider=cloudflared
47+
ddev config --share-default-provider=cloudflared
4848

4949
# Set global default for all projects
50-
ddev config global --share-provider=cloudflared
50+
ddev config global --share-default-provider=cloudflared
5151
```
5252

5353
This flexibility lets you use different providers for different projects or standardize across your entire development setup.
5454

55-
## Automation with DDEV_SHARE_URL
55+
## Automation for difficult CMSs using `pre-share` hooks and $DDEV_SHARE_URL
5656

5757
When you run `ddev share`, DDEV now exports the tunnel URL as the `DDEV_SHARE_URL` environment variable. This enables automation through hooks, particularly useful for integration testing, webhooks, or CI workflows that need the public URL.
5858

59-
A practical example: sharing WordPress or TYPO3 sites used to require manual database updates to replace localhost URLs with the share URL. Now you can automate this with pre-share hooks that run before the tunnel starts:
59+
### WordPress Example
60+
61+
WordPress is always difficult because it embeds the URL right in the database. For site moves to new URLs the `wp search-replace` tool is the classic way to deal with this, so the hook demonstration below can be used to make `ddev share` work even when the URL is dynamic.
6062

6163
```yaml
6264
# .ddev/config.yaml
6365
hooks:
6466
pre-share:
65-
- exec: |
66-
if [ -n "$DDEV_SHARE_URL" ]; then
67-
# WordPress example
68-
wp search-replace "https://myproject.ddev.site" "$DDEV_SHARE_URL" --quiet
69-
fi
67+
# provider DDEV_SHARE_URL in container
68+
- exec-host: echo "${DDEV_SHARE_URL}" >.ddev/share_url.txt
69+
# Save database for restore later
70+
- exec-host: ddev export-db --file=/tmp/tmpdump.sql.gz
71+
# Change the URL in the database
72+
- exec: wp search-replace ${DDEV_PRIMARY_URL} $(cat /mnt/ddev_config/share_url.txt) | grep Success
73+
# Fix the wp-config-ddev.php to use the DDEV_SHARE_URL
74+
- exec: cp wp-config-ddev.php wp-config-ddev.php.bak
75+
- exec: sed -i.bak "s|${DDEV_PRIMARY_URL}|$(cat /mnt/ddev_config/share_url.txt)|g" wp-config-ddev.php
76+
- exec: wp cache flush
77+
post-share:
78+
# Put back the things we changed
79+
- exec: cp wp-config-ddev.php.bak wp-config-ddev.php
80+
- exec-host: ddev import-db --file=/tmp/tmpdump.sql.gz
7081
```
7182
7283
This approach works for any CMS that stores base URLs in its configuration or database. The pre-share hook updates URLs automatically, and you can use post-share hooks to restore them when sharing ends. This eliminates the manual configuration work that sharing previously required for many CMSs.
7384
85+
### TYPO3 Example
86+
87+
TYPO3 usually puts the site URL into config/sites/*/config.yaml as `base: <url>`, and then it won't respond to the different URLs in a `ddev share`. The hooks here temporarily remove teh `base:` element:
88+
89+
```yaml
90+
hooks:
91+
pre-share:
92+
# Make a backup of config/sites
93+
- exec: cp -r ${DDEV_APPROOT}/config/sites ${DDEV_APPROOT}/config/sites.bak
94+
- exec-host: echo "removing 'base' from site config for sharing to ${DDEV_SHARE_URL}"
95+
# Remove `base:` from the various site configs
96+
- exec: sed -i 's|^base:|#base:|g' ${DDEV_APPROOT}/config/sites/*/config.yaml
97+
- exec-host: echo "shared on ${DDEV_SHARE_URL}"
98+
post-share:
99+
# Restore the original configuration
100+
- exec: rm -rf ${DDEV_APPROOT}/config/sites
101+
- exec: mv ${DDEV_APPROOT}/config/sites.bak ${DDEV_APPROOT}/config/sites
102+
- exec-host: ddev mutagen sync
103+
- exec-host: echo "changes to config/sites reverted"
104+
105+
```
106+
74107
## Extensibility: Custom Share Providers
75108

76109
The new provider system is script-based, allowing you to create custom providers for internal tunneling solutions or other services. Place Bash scripts in `.ddev/share-providers/` (project-level) or `~/.ddev/share-providers/` (global), and DDEV will recognize them as available providers.

0 commit comments

Comments
 (0)