pinga/vizima

v1.0.1 2023-03-14 15:23 UTC

This package is auto-updated.

Last update: 2024-09-18 17:27:37 UTC


README

StandWithUkraine

SWUbanner

Vizima

Vizima 是一个高性能的 API 微框架,旨在帮助您使用 PHP 创建强大的 API。该项目是将流行的 Mark 框架移植到 Swoole 的项目。

安装

composer require pinga/vizima

用法

# start.php

<?php

require 'vendor/autoload.php';

$app = new \Vizima\App('0.0.0.0', 8080);

$app->get('/', function() {
    return '<h1>Hello, world!</h1>';
});

$app->get('/hello/{name}', function (Swoole\Http\Request $request, $name) {
    return "Hello $name";
});

$app->post('/user/create', function () {
    return json_encode(['code'=>0 ,'message' => 'ok']);
});

$app->start();

运行命令 php start.php

访问 http://127.0.0.1:3000/hello/world 将会显示 "Hello world"。

基准测试

Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     3.07ms    4.27ms  92.46ms   92.61%
    Req/Sec     2.56k   801.21    17.84k    67.79%
  1221250 requests in 30.10s, 203.82MB read
Requests/sec:  40575.11
Transfer/sec:      6.77MB

支持

如果您有任何问题,请毫不犹豫地提出问题。