folk / laravel
Laravel integration for Folk application server
v0.4.2
2026-07-09 15:45 UTC
Requires
- php: >=8.2
- folk/sdk: ^0.4.1
- laravel/framework: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
README
Laravel adapter for Folk. Provides seamless integration -- all your routes, middleware, and controllers work without changes.
Version: 0.2.0
Installation
composer require folk/laravel
Auto-discovery registers FolkServiceProvider, which auto-registers LaravelHttpHandler for HTTP dispatch.
Requirements
- PHP 8.2+ (ZTS build)
- Laravel 11+
- folk/sdk
folk.soextension
Setup
- Install the package:
composer require folk/laravel
- Create
folk.tomlin your project root:
[workers] script = "server.php" count = 4 [http] listen = "0.0.0.0:8080"
- Create
server.phpentry point:
<?php require __DIR__ . '/vendor/autoload.php'; $app = require __DIR__ . '/bootstrap/app.php'; $app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); $loop = new \Folk\Sdk\Worker\WorkerLoop(); $loop->registerHttpHandler( $app->make(\Folk\Laravel\Http\LaravelHttpHandler::class) ); $loop->run();
- Build and run:
folk-builder build ./my-folk serve
How it works
FolkServiceProviderregistersLaravelHttpHandlerin the containerLaravelHttpHandlerconverts Folk's request arrays (received as native PHP arrays via zval) into LaravelRequestobjects- After the Laravel kernel processes the request, the response is converted back to a Folk response array
- No JSON encode/decode -- direct zval arrays between Rust and PHP
State resetters
Between every request, built-in resetters clean up shared state:
| Resetter | What it does |
|---|---|
AuthResetter |
Forgets authenticated user |
DatabaseResetter |
Rolls back open transactions |
EventResetter |
Clears request-scoped listeners |
QueueResetter |
Reconnects queue connections |
License
MIT