aerni/cloudflared
Composer 安装命令:
composer require aerni/cloudflared
包简介
A Laravel package to create and manage Cloudflare Tunnels for local development
README 文档
README
A simple package to create and manage Cloudflare Tunnels for your Laravel projects. Cloudflare Tunnels give you instant public access to your local development environment, similar to Expose or ngrok, but powered by Cloudflare. Perfect for testing webhooks and sharing work-in-progress.
Pair it with Cloudflared for Vite to get seamless tunneled access to both your Laravel app and Vite's dev server, making it effortless to debug your frontend on real devices like your iPhone.
Prerequisites
- Install cloudflared
- Run
cloudflared tunnel loginto authenticate the desired domain - Install Laravel Herd
Installation
Install the package using Composer:
composer require aerni/cloudflared
Keep APP_URL set to your local Herd URL (e.g. http://myapp.test). Do not set it to the public tunnel hostname. That would make cloudflared forward traffic to itself. While the tunnel is running, the package automatically rewrites URL generation to the public Cloudflare URL in web requests, queue workers, and scheduled commands. You never need to edit .env whether the tunnel is active or not.
Basic Usage
Creating a tunnel
Create a tunnel for your project with a single command. This will create a Cloudflare tunnel, configure DNS records, set up a Herd link, and save the configuration to .cloudflared.yaml in your project root.
php artisan cloudflared:install
Note: Run this command again to modify the existing installation. Change the subdomain, create or repair DNS records, or delete and recreate the tunnel.
Running the tunnel
Start the tunnel to make your local site publicly accessible.
php artisan cloudflared:run
Deleting the tunnel
Remove the tunnel, DNS records, and configuration when you no longer need it.
php artisan cloudflared:uninstall
Good to know
Trusted proxies
Signed URL validation and HTTPS detection through the tunnel rely on Laravel honoring X-Forwarded-Proto from Cloudflare. This is the same TrustProxies setup you'd use behind any TLS-terminating proxy. Most production apps already have this configured.
Long-running queue workers
The URL rewrite is captured once when the worker boots. Restart long-running workers after starting or stopping the tunnel so new URLs pick up the change.
Config caching
Make sure your config isn't cached while the tunnel is up. The rewrite runs during bootstrap, so the tunnel URL would get serialized into the cached config and pin there. Clear your config cache if this happens.
License
This package is open-sourced software licensed under the MIT license.
Credits
Developed by Michael Aerni
Support
For issues and questions, please use the GitHub Issues page.
aerni/cloudflared 适用场景与选型建议
aerni/cloudflared 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.59k 次下载、GitHub Stars 达 87, 最近一次更新时间为 2025 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aerni/cloudflared 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aerni/cloudflared 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 87
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-12