PHPackages                             fqapps/swoole-gin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. fqapps/swoole-gin

ActiveLibrary[HTTP &amp; Networking](/categories/http)

fqapps/swoole-gin
=================

teaching repo

v1.0.2(4y ago)131MITPHPPHP ^8.0

Since Mar 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lazychanger/swoole-gin)[ Packagist](https://packagist.org/packages/fqapps/swoole-gin)[ RSS](/packages/fqapps-swoole-gin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (12)Versions (5)Used By (1)

swoole-gin
==========

[](#swoole-gin)

Teaching warehouse

[中文](./README_CN.md)
--------------------

[](#中文)

[Document](./docs/00_Summary.md)
--------------------------------

[](#document)

How to install
--------------

[](#how-to-install)

```
$ composer require swoole/swoole-gin
```

Usage
-----

[](#usage)

```
declare(strict_types=1);

use SwooleGin\Gin\Context\Context;
use SwooleGin\Gin\Context\ContextHandlerFuncInterface;
use SwooleGin\Gin\Gin;
use SwooleGin\Gin\Middleware\FaviconMiddleware;
use SwooleGin\Options;
use SwooleGin\Server;
use SwooleGin\Stream\StringStream;
use SwooleGin\Utils\HTTPStatus;

include_once __DIR__ . '/../vendor/autoload.php';

$servOpts = new Options();
$servOpts->setAddr('0.0.0.0:8082');

$serv = new Server($servOpts);

$engine = new Gin();
$engine->use(
    (new FaviconMiddleware),
    // 假鉴权中间件
    (new class implements ContextHandlerFuncInterface {
        public function __invoke(Context $context)
        {
            if ($context->query('token') !== '123456') {
                $context->response->withBody(new StringStream('authorized failed'));
                $context->response->withStatus(HTTPStatus::StatusForbidden);
                $context->abort();
            }
        }
    }),
    // 用于模拟洋葱结构中间件：打印响应内容
    (new class implements ContextHandlerFuncInterface {
        public function __invoke(Context $context)
        {
            $context->next();

            $body = $context->response->getBody()->getContents();
            echo 'resp:', $body, PHP_EOL;
            $context->response->withBody(new StringStream($body));
        }
    }),
);
$engine->GET('/hello', (new class implements ContextHandlerFuncInterface {
    public function __invoke(Context $context)
    {
        $context->Raw(HTTPStatus::StatusOK, 'hello world');
    }
}));

$engine->setOnNotFound((new class implements ContextHandlerFuncInterface {
    public function __invoke(Context $context)
    {
        $context->JSON(HTTPStatus::StatusOK, ['code' => HTTPStatus::StatusNotFound, 'msg' => 'not found']);
    }

}));

$serv->setHandler($engine);

// server run
$serv->serve();
```

todo
----

[](#todo)

- middleware
- context
- gin-router

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

4

Last Release

1472d ago

Major Versions

v0.0.1 → v1.0.02022-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/18ad91cd8941a8d5a576407d3699cdb7667c1fc57a88ce77e761616499f9f03b?d=identicon)[lazychanger](/maintainers/lazychanger)

---

Top Contributors

[![lazychanger](https://avatars.githubusercontent.com/u/20916944?v=4)](https://github.com/lazychanger "lazychanger (1 commits)")

---

Tags

httphttp-protocolphpswoolehttpswoole

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fqapps-swoole-gin/health.svg)

```
[![Health](https://phpackages.com/badges/fqapps-swoole-gin/health.svg)](https://phpackages.com/packages/fqapps-swoole-gin)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
