分享一个自己做的基于swoole的多进程全协程Web框架

Watish WEB

一个swoole驱动的多进程全协程的轻量Web框架

github.com/Watish/WatishWEB

支持websocket通信,多进程广播消息
路由注解,中间件注解
支持依赖注入
支持异步任务投递
支持Crontab定时任务
支持独立进程
……

话不多说,直接贴个Demo示例

<?php

namespace Watish\WatishWEB\Controller;

use Watish\Components\Attribute\Inject;
use Watish\Components\Attribute\Middleware;
use Watish\Components\Attribute\Path;
use Watish\Components\Attribute\Prefix;
use Watish\Components\Struct\Request;
use Watish\WatishWEB\Middleware\TestMiddleware;
use Watish\WatishWEB\Service\BaseService;

#[Prefix('/hello')]
#[Middleware([TestMiddleware::class])]
class HelloController
{
    #[Inject(BaseService::class)]
    public BaseService $baseService;

    #[Path('/index')]
    public function index(Request $request) :array
    {
        return [
            "msg" => $this->baseService->toArray(["Hello",'World'])
        ];
    }

    #[Path('/user/{name}',['GET','POST'])]
    public function msg(Request $request) :array
    {
        return [
            "msg" => "hello ".$request->route('name')
        ];
    }
}

本人很喜欢这种注解式的代码风格,可以少写很多配置和构造方法
具体请访问 github.com/Watish/WatishWEB
求求大佬们点个Star吧😜

再贴个压测图(图个乐凑个数)
测试环境:Ubuntu22.0.4 LTS
测试硬件:VirtualBox 6C6T 8192M 开启虚拟化支持
测试工具:ApacheBenchmark ,-c 3000 -n 30000
压测娱乐图

讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!