Download the PHP package solution-forest/cloudflare-tunnel without Composer

On this page you can find all versions of the php package solution-forest/cloudflare-tunnel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cloudflare-tunnel

solution-forest/cloudflare-tunnel

PHP GitHub

Composer bin that wraps cloudflared so any local HTTP server gets a public HTTPS URL in one command.

Contents


Features


Requirements


Installation

1. Require the package (Packagist)

Or in composer.json:

No repositories entry is required — the package is on Packagist.

Alternatives (path / VCS) **Path (local package development):** **VCS (without Packagist):**

2. Install cloudflared

Other platforms: Cloudflare downloads.

3. Run

Start your local app, then:

Optional project script (this package does not ship Composer scripts; add them in the consuming app if you want):

When the public URL appears, set your app’s public base URL to that HTTPS origin (e.g. APP_URL), restart the local server, and clear any config cache.


Configuration

CLI flags

Flag Description
--url=URL Local origin to expose (e.g. http://127.0.0.1:9000)
--port=PORT Local port; host from HOST or 127.0.0.1
-h, --help Show help

Environment variables

Variable Default Purpose
TUNNEL_LOCAL_URL (auto / default) Full local origin (highest priority)
HOST / PORT 127.0.0.1 / (unset) Used when TUNNEL_LOCAL_URL / --url unset; PORT must be set to take this path
TUNNEL_NAME (empty) Named tunnel; alias CLOUDFLARE_TUNNEL_NAME
CLOUDFLARED_CONFIG ~/.cloudflared/config.yml Named-tunnel config path
CLOUDFLARED_EXTRA_ARGS (empty) Extra args passed to cloudflared (space-separated)

Local URL resolution (first match wins)

The script prints which URL was chosen and why.

Priority Source Notes
1 TUNNEL_LOCAL_URL Full URL
2 --url= CLI full URL
3 PORT / --port= Host from HOST or 127.0.0.1
4 Auto-detect Heuristic below
5 Default http://127.0.0.1:8000

Auto-detect:

  1. If ./.env has APP_URL=http://127.0.0.1:PORT or http://localhost:PORT (explicit port), use that host/port.
  2. Else probe listening ports via lsof (or nc): 8000, 8080, 3000, 80.
  3. Otherwise fall back to http://127.0.0.1:8000.

Port 5173 alone is treated as Vite, not the app — auto-detect does not prefer it as the tunnel target.

Quick vs named tunnels

Mode How Notes
Quick (default) No TUNNEL_NAME Random https://….trycloudflare.com; fine for short-lived OAuth/webhook labs
Named TUNNEL_NAME=… Requires config at CLOUDFLARED_CONFIG; DNS/ingress must match your public hostname and local target

Testing

This package ships no automated test suite and no dry-run / mock mode for cloudflared. Verify changes with the checks below.

Syntax check

From the package root:

Exit 0 means the script parses under Bash.

Help / missing binary smoke

Manual smoke (end-to-end)

  1. Start a local HTTP server on a known port (e.g. php -S 127.0.0.1:8000 or php artisan serve).
  2. In another terminal: vendor/bin/cloudflare-tunnel (or bin/cloudflare-tunnel --port=8000 from the package tree).
  3. Wait for a https://….trycloudflare.com URL in the output.
  4. Open that URL in a browser and confirm it reaches the local app.
  5. Stop with Ctrl+C.

Optional Composer scripts

The package composer.json defines no scripts. Consuming projects may add a tunnel script (see Installation) and run composer run tunnel as a convenience wrapper — that is project-local, not part of this package’s release verification.


Why

Localhost is enough for most day-to-day work. It is not enough when something on the public internet must call you back:

Alternatives exist. Herd Expose (herd share) is polished for Laravel Herd + Vite. ngrok is widely known and feature-rich. This package is a thin, Composer-installable wrapper around Cloudflare’s free quick tunnel (and optional named tunnels) — useful when you already have (or prefer) cloudflared, want a vendor/bin entry point, and do not need Herd or an ngrok account for the job.

It does not replace those tools; it is another path with the same job: local app → public HTTPS.


How it works

  1. The script resolves a local origin (env, CLI flags, auto-detect, or default :8000).
  2. With no TUNNEL_NAME, it runs a quick tunnel and prints a https://….trycloudflare.com URL.
  3. With TUNNEL_NAME set, it runs that named tunnel from ~/.cloudflared/config.yml (or CLOUDFLARED_CONFIG).
  4. You point OAuth redirect URIs / webhooks / APP_URL at the public HTTPS origin — not http://localhost.

Use cases

Scenario Why a tunnel helps
OAuth callbacks Providers reject http://localhost or require HTTPS
Webhooks External services POST to a reachable URL
Share WIP Teammate opens your branch without VPN
Mobile testing Phone hits the same app over HTTPS
Laravel + Google OAuth Lab Connect flows need a stable-enough HTTPS APP_URL
Non-Laravel (Node, etc.) Same bin; no framework coupling

Laravel notes

This package is not Laravel-specific. When you use it with Laravel:

Avoid composer run dev + Vite HMR behind the tunnel

composer run dev / php artisan dev typically serves the app and Vite on localhost:5173. The tunnel can reach your app origin, but the browser on https://….trycloudflare.com still tries to load assets from http://localhost:5173 → mixed content / broken CSS & JS.

Recommended flow (OAuth / webhooks)

  1. Build assets: npm run build
  2. Serve the app only: php artisan serve (or Herd’s PHP site)
  3. In another terminal: vendor/bin/cloudflare-tunnel (or composer run tunnel)
  4. Set APP_URL to the printed public HTTPS URL, then php artisan config:clear and restart the app server
  5. Point OAuth redirect URIs at ${APP_URL}/…

Do not fold the tunnel into default composer run dev: quick tunnels mint a new hostname every start (breaking APP_URL / redirect URIs), and public exposure should stay opt-in.

Herd alternative

Herd users may prefer herd share for Vite-aware public sharing instead of (or alongside) this helper.


License

MIT © Solution Forest


All versions of cloudflare-tunnel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package solution-forest/cloudflare-tunnel contains the following files

Loading the files please wait ...