folk / laravel
Laravel integration for Folk application server
v0.4.7
2026-08-02 11:24 UTC
Requires
- php: >=8.2
- folk/sdk: ^0.4.6
- laravel/framework: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel adapter for Folk. Provides seamless integration -- all your routes, middleware, and controllers work without changes.
Installation
composer require folk/laravel
Auto-discovery registers FolkServiceProvider, which auto-registers LaravelHttpHandler for HTTP dispatch.
Requirements
- PHP 8.2+ — a standard non-thread-safe (NTS) build; Folk forks worker processes, so no thread-safe PHP is needed
- Laravel 11+
- folk/sdk
- the
folk.soextension (pie install folk-project/ext-folk)
Setup
- Install the package:
composer require folk/laravel
- Create
folk.tomlin your project root:
[workers] script = "vendor/bin/folk-server" count = 4 [http] listen = "0.0.0.0:8080" public_dir = "public" # serve built assets from disk; a miss falls through to Laravel
- Run:
php vendor/bin/folk-server
The entry point ships with this package (bin/folk-server) -- there is no worker
script to write. Composer's bin-proxy (vendor/bin/folk-server) works as well.
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 the authenticated user and all resolved guards |
SessionResetter |
Drops the request's session instance |
DatabaseResetter |
Rolls back open transactions |
EventResetter |
Clears request-scoped listeners |
QueueResetter |
Reconnects queue connections |
ScopedResetter |
Forgets the container's scoped instances |
InertiaResetter |
Clears Inertia's shared props |
Register your own via config/folk.php:
'resetters' => [ App\Folk\MyStateResetter::class, // implements Folk\Sdk\Reset\ResettableInterface ],
License
MIT — see LICENSE.