PHPackages                             swoole/library - 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. swoole/library

ActiveLibrary

swoole/library
==============

Library of Swoole

v6.0.2(1y ago)2496.5k↓50%58[3 PRs](https://github.com/swoole/library/pulls)Apache-2.0PHPPHP &gt;=8.1CI passing

Since Dec 6Pushed 4mo ago27 watchersCompare

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

READMEChangelog (9)Dependencies (3)Versions (25)Used By (0)

Swoole Library
==============

[](#swoole-library)

[![Twitter](https://camo.githubusercontent.com/938a48bafad518c277315ee27ebefa0a0ca9f7cde918eef1820810964ff6e9f5/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f747769747465723f69636f6e3d74776974746572266c6162656c)](https://twitter.com/phpswoole)[![Discord](https://camo.githubusercontent.com/155081771f1f717ebd6be59f0cb88fb4ac65ee4a70fec13715509f7e280fdd50/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f646973636f72643f69636f6e3d646973636f7264266c6162656c)](https://discord.swoole.dev)[![Library Status](https://github.com/swoole/library/workflows/Unit%20Tests/badge.svg)](https://github.com/swoole/library/actions)[![License](https://camo.githubusercontent.com/1d48dd9fe6bf24b648040a29de372f089b9340226a4fb00214784dfb402cdda1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d617061636865322d626c75652e737667)](LICENSE)

Dockerized Local Development
----------------------------

[](#dockerized-local-development)

First, run one of the following commands to install development packages using *Composer*:

```
docker run --rm -v "$(pwd)":/var/www -ti phpswoole/swoole composer update -n

# or, use the official Composer Docker image:
docker run --rm -v "$(pwd)":/app -ti composer update -n --ignore-platform-reqs

# or, use the local Composer if installed:
composer update -n --ignore-platform-reqs
```

Next, you need to start Docker containers:

```
docker compose up -d
```

Alternatively, if you need to rebuild some Docker image and to restart the containers:

```
docker compose build --progress plain --no-cache
docker compose up -d --force-recreate
```

Now you can create a `bash` session in the `app` container:

```
docker compose exec app bash
```

And run commands inside the container:

```
composer test
```

Or you can run commands directly inside the `app` container:

```
docker compose exec app composer test
```

Examples
--------

[](#examples)

Once you have Docker containers started (as discussed in previous section), you can use commands like following to run examples under folder [examples](https://github.com/swoole/library/tree/master/examples).

### Examples of Database Connection Pool

[](#examples-of-database-connection-pool)

```
docker compose exec app php examples/mysqli/base.php
docker compose exec app php examples/pdo/base.php
docker compose exec app php examples/redis/base.php
```

### Examples of FastCGI Calls

[](#examples-of-fastcgi-calls)

There is a fantastic example showing how to use Swoole as a proxy to serve a WordPress website using PHP-FPM. Just open URL *http://127.0.0.1* in the browser and check what you see there. Source code of the example can be found [here](https://github.com/swoole/library/blob/master/examples/fastcgi/proxy/wordpress.php).

Here are some more examples to make FastCGI calls to PHP-FPM:

```
docker compose exec app php examples/fastcgi/greeter/call.php
docker compose exec app php examples/fastcgi/greeter/client.php
docker compose exec app php examples/fastcgi/proxy/base.php
docker compose exec app php examples/fastcgi/var/client.php
```

Third Party Libraries
---------------------

[](#third-party-libraries)

Here are all the third party libraries used in this project:

- The FastCGI part is derived from Composer package [lisachenko/protocol-fcgi](https://github.com/lisachenko/protocol-fcgi).

You can find the licensing information of these third party libraries [here](https://github.com/swoole/library/blob/master/THIRD-PARTY-NOTICES).

License
-------

[](#license)

This project follows the [Apache 2 license](https://github.com/swoole/library/blob/master/LICENSE).

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance59

Moderate activity, may be stable

Popularity44

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~92 days

Recently: every ~23 days

Total

21

Last Release

503d ago

Major Versions

v0.1.0 → v4.5.x-dev2021-02-19

4.8.x-dev → v5.0.32023-04-26

v5.1.8 → v6.0.0-alpha2024-03-22

PHP version history (5 changes)v0.1.0PHP ^7.1

v4.5.x-devPHP &gt;=7.1

4.8.x-devPHP &gt;=7.2

v5.1.2PHP &gt;=8.0

v6.0.0-betaPHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1dea9261ba377a13a16e7e0f3883e73bda4094551ddea280e852f23a5d248c0?d=identicon)[Tianfeng.Han](/maintainers/Tianfeng.Han)

![](https://www.gravatar.com/avatar/1bdf9390d85a45dad64fe58584f55824c12a134a04e338d6259845683d9db137?d=identicon)[twosee](/maintainers/twosee)

---

Top Contributors

[![deminy](https://avatars.githubusercontent.com/u/865547?v=4)](https://github.com/deminy "deminy (189 commits)")[![matyhtf](https://avatars.githubusercontent.com/u/2017766?v=4)](https://github.com/matyhtf "matyhtf (119 commits)")[![twose](https://avatars.githubusercontent.com/u/25978241?v=4)](https://github.com/twose "twose (86 commits)")[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (74 commits)")[![leocavalcante](https://avatars.githubusercontent.com/u/183722?v=4)](https://github.com/leocavalcante "leocavalcante (14 commits)")[![huanghantao](https://avatars.githubusercontent.com/u/22836925?v=4)](https://github.com/huanghantao "huanghantao (11 commits)")[![yunbaoi](https://avatars.githubusercontent.com/u/34161114?v=4)](https://github.com/yunbaoi "yunbaoi (5 commits)")[![NathanFreeman](https://avatars.githubusercontent.com/u/33935209?v=4)](https://github.com/NathanFreeman "NathanFreeman (4 commits)")[![djw1028769140](https://avatars.githubusercontent.com/u/27218376?v=4)](https://github.com/djw1028769140 "djw1028769140 (3 commits)")[![DevZer0x00](https://avatars.githubusercontent.com/u/41948243?v=4)](https://github.com/DevZer0x00 "DevZer0x00 (2 commits)")[![doubaokun](https://avatars.githubusercontent.com/u/313478?v=4)](https://github.com/doubaokun "doubaokun (2 commits)")[![jcheron](https://avatars.githubusercontent.com/u/2511052?v=4)](https://github.com/jcheron "jcheron (2 commits)")[![NHZEX](https://avatars.githubusercontent.com/u/14545600?v=4)](https://github.com/NHZEX "NHZEX (2 commits)")[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (1 commits)")[![fakharksa](https://avatars.githubusercontent.com/u/106683667?v=4)](https://github.com/fakharksa "fakharksa (1 commits)")[![kingIZZZY](https://avatars.githubusercontent.com/u/1576535?v=4)](https://github.com/kingIZZZY "kingIZZZY (1 commits)")[![landso](https://avatars.githubusercontent.com/u/7994497?v=4)](https://github.com/landso "landso (1 commits)")[![lbbniu](https://avatars.githubusercontent.com/u/6211983?v=4)](https://github.com/lbbniu "lbbniu (1 commits)")[![maxiaozhi](https://avatars.githubusercontent.com/u/34503138?v=4)](https://github.com/maxiaozhi "maxiaozhi (1 commits)")[![shiguangqi](https://avatars.githubusercontent.com/u/654869?v=4)](https://github.com/shiguangqi "shiguangqi (1 commits)")

---

Tags

libraryphpstandard-libraryswoolelibraryswoole

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)[hamlet-framework/type

Hamlet Framework / Type

2040.9k4](/packages/hamlet-framework-type)

PHPackages © 2026

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