zephirorb / zro
zRo 是一个基于 workerman 的 PHP 微型框架,可以帮助您快速编写简单而强大的 Web 应用程序和 API
v1.1
2020-05-15 14:14 UTC
Requires
- php: >=7.1
- nikic/fast-route: ^1.3
- workerman/workerman: ^4.0.4
Suggests
- ext-event: For better performance.
This package is auto-updated.
Last update: 2024-09-19 19:22:02 UTC
README
zRo 是一个基于 workerman 的微型框架,可以帮助您快速使用 PHP 编写 API。
安装
建议使用 Composer 安装 zRo。
composer require zephirorb/zro
使用方法
index.php
<?php require __DIR__ . '/vendor/autoload.php'; use zRo\App; $zro = new App('http://0.0.0.0:3000'); // 10 processes $zro->count = 10; $zro->any('/', function ($request) { return 'Hello world'; }); $zro->post('/articles/create', function ($request) { return json_encode(['code'=>0 ,'message' => 'ok']); }); $zro->get('/hello/{name}', function ($request, $name) { return "Hello $name"; }); $zro->start();
运行命令 php index.php start -d
访问 http://127.0.0.1:3000/hello/world 将显示 "Hello world"。
可用命令
php index.php restart -d
php index.php stop
php index.php status
php index.php connections
Nginx
如果您想将 Nginx 用作 Comet 应用程序的反向代理或负载均衡器,请将以下行插入 nginx.conf 中
http {
upstream app {
server https://:port;
}
server {
listen 80;
location / {
proxy_pass http://app;
proxy_redirect off;
}
}
}
许可证
zRo 框架采用 MIT 许可证授权。有关更多信息,请参阅许可证文件。