veasin/nx-tiny-franken
最新稳定版本:0.0.2
Composer 安装命令:
composer require veasin/nx-tiny-franken
包简介
FrankenPHP worker integration for nx-tiny micro-framework.
README 文档
README
FrankenPHP worker mode adapter for nx-tiny micro-framework.
Install
composer require veasin/nx-tiny-franken
Usage
<?php // franken.php - FrankenPHP worker entry point include __DIR__ . '/vendor/autoload.php'; use function nx\{container, franken, from, log, output, route}; container('count', 0); franken(function () { log(from('uri', 'input')); route([ 'get:/' => fn() => output('hello world!', 'http'), 'get:/hi' => fn() => output('hi~', 'http'), 'get:/count' => function () { $count = container('count') + 1; output("count: $count", 'http'); container('count', $count); }, ]); }, function () { // cleanup on each request cycle end });
Caddyfile
localhost { log root demo/ php_server { try_files {path} franken.php worker { file ./demo/franken.php watch ./src/**/*.php watch ./demo/**/*.php num 4 } } }
Run with:
frankenphp run --config demo/Caddyfile
API
franken(callable $worker, ?callable $clear): void
Wraps the FrankenPHP worker loop:
- Sets up a PSR-3 compatible logger via
frankenphp_log()on first call. - Calls
$worker()on each request. If$worker()returns a truthy value, subsequent output/cleanup is skipped. - Calls
$clear()after each request cycle ends (if callable).
License
LGPL-3.0-or-later
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2026-05-10