kieranbrown/laraworker
Composer 安装命令:
composer require kieranbrown/laraworker
包简介
Run Laravel on Cloudflare Workers via php-cgi-wasm
README 文档
README
Deploy Laravel applications to Cloudflare Workers via PHP WASM.
Laraworker packages your Laravel app into a compressed tar archive, then runs it on Cloudflare Workers using php-cgi-wasm. On each request, the Worker unpacks the app into an in-memory filesystem and processes it through the PHP WASM runtime — no traditional server required.
Requirements
- PHP 8.5+
- Laravel 12
- Node.js or Bun
- A Cloudflare account
Installation
composer require kieranbrown/laraworker
Then run the install command to configure your project:
php artisan laraworker:install
This will:
- Publish the
config/laraworker.phpconfiguration file - Add build scripts and dependencies to
package.json - Update
.gitignoreto exclude the.laraworker/build directory - Install npm dependencies (
php-cgi-wasm,wrangler, etc.) - Run an initial build into
.laraworker/
Configuration
After installation, configure your setup in config/laraworker.php:
return [ // PHP extensions to include in the WASM bundle 'extensions' => [ 'mbstring' => true, // ~742 KiB gzipped 'openssl' => true, // ~936 KiB gzipped ], // Directories included in the app bundle (relative to project root) 'include_dirs' => [ 'app', 'bootstrap', 'config', 'database', 'routes', 'resources/views', 'vendor', ], // Individual files to include 'include_files' => [ 'public/index.php', 'artisan', 'composer.json', ], // Regex patterns for files to exclude 'exclude_patterns' => [ '/\.git\//', '/\/node_modules\//', '/\/tests\//', // ... ], ];
Wrangler Configuration
Deployment settings like worker_name, account_id, and compatibility_date are configured in config/laraworker.php. The wrangler.jsonc is auto-generated into .laraworker/ at build time from these config values.
Usage
Laraworker provides five Artisan commands:
laraworker:install
Configure the project for Cloudflare Workers and run an initial build.
php artisan laraworker:install
php artisan laraworker:install --force # Overwrite existing files
laraworker:build
Build the Laravel application for production deployment. Caches config, routes, and views, then packages everything into app.tar.gz.
php artisan laraworker:build
laraworker:dev
Build and start a local development server using wrangler dev.
php artisan laraworker:dev
laraworker:deploy
Build and deploy to Cloudflare Workers.
php artisan laraworker:deploy
php artisan laraworker:deploy --dry-run # Build without deploying
laraworker:status
Check installation status, bundle sizes, and tier compatibility.
php artisan laraworker:status
How It Works
- Build — Your Laravel app is optimized (cached config/routes/views, classmap autoload) and packaged into a compressed
app.tar.gz - Deploy — The archive and PHP WASM binary are deployed to Cloudflare Workers as static assets
- Request — On cold start, the Worker fetches
app.tar.gz, unpacks it into an in-memory filesystem (MEMFS), and boots the PHP runtime - Process — Each HTTP request is routed through
php-cgi-wasm, which executes your Laravel application and returns the response
The entire bundle (WASM binary + app archive + Worker code) fits within Cloudflare Workers' free tier limit of 3 MB.
Custom Domain Setup
To serve your app from a custom domain, configure your Cloudflare account with the domain and set up routes. The wrangler.jsonc is auto-generated at build time from config/laraworker.php — for advanced wrangler settings, you can customize the stubs/wrangler.jsonc.stub template.
Make sure your domain is added to your Cloudflare account and DNS is configured.
Extensions
Two PHP extensions can be toggled in config/laraworker.php:
| Extension | Default | Size Impact |
|---|---|---|
mbstring |
Enabled | ~742 KiB gzipped |
openssl |
Enabled | ~936 KiB gzipped |
Disabling unused extensions reduces your bundle size, which can help stay within Cloudflare's tier limits.
License
Laraworker is open-sourced software licensed under the MIT license.
kieranbrown/laraworker 适用场景与选型建议
kieranbrown/laraworker 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 67 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「cloudflare」 「workers」 「wasm」 「php-wasm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kieranbrown/laraworker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kieranbrown/laraworker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kieranbrown/laraworker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A gearman plugin for CakePHP 3
Get notified when supervisor is down.
PHP library for dispatching, handling and managing Gearman Workers
A simple queue utility plugin for Kirby 3. It enables workers in Kirby that can do tasks (in the background) at scheduled intervals (cron) by working through queues of jobs.
Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.
A modular queue system featuring multiple storage drivers, scalable workers, job batching, chaining, rate limiting, events, and an intuitive CLI for managing jobs.
统计信息
- 总下载量: 67
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-26