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

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

klsoft/yii3-swoole
==================

The package provides the Swoole HTTP server for the Yii 3 application

1.0.0(1w ago)00MITPHP

Since May 31Pushed 1w agoCompare

[ Source](https://github.com/klsoft-web/yii3-swoole)[ Packagist](https://packagist.org/packages/klsoft/yii3-swoole)[ Docs](https://github.com/klsoft-web/yii3-swoole)[ RSS](/packages/klsoft-yii3-swoole/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

YII3-SWOOLE
===========

[](#yii3-swoole)

The package provides the Swoole HTTP server for the [Yii 3](https://yii3.yiiframework.com) application.

Requirement
-----------

[](#requirement)

- PHP 8.2 or higher.
- [Swoole](https://github.com/swoole/swoole-src) PHP extension 6.2.0 or higher.

Installation
------------

[](#installation)

```
composer require klsoft/yii3-swoole
```

How to use
----------

[](#how-to-use)

Configure the [resetting of service states](https://github.com/yiisoft/di#resetting-services-state).

For web applications that use `AssetManager`, add the following to the `config/web/di/application.php` file:

```
use Yiisoft\Aliases\Aliases;
use Yiisoft\Assets\AssetManager;
use Yiisoft\Assets\AssetLoaderInterface;
use Yiisoft\Assets\AssetConverterInterface;
use Yiisoft\Assets\AssetRegistrar;

return [
    // ...
    AssetManager::class => [
        'definition' =>  static function (ContainerInterface $container) use ($params): AssetManager {
            $assetManager = new AssetManager(
                $container->get(Aliases::class),
                $container->get(AssetLoaderInterface::class),
                $params['yiisoft/assets']['assetManager']['allowedBundleNames'],
                $params['yiisoft/assets']['assetManager']['customizedBundles'],
            );

            $assetManager = $assetManager
                ->withConverter($container->get(AssetConverterInterface::class));

            if ($params['yiisoft/assets']['assetManager']['publisher'] !== null) {
                $assetManager = $assetManager->withPublisher(
                    $container->get($params['yiisoft/assets']['assetManager']['publisher'])
                );
            }

            $assetManager->registerMany($params['yiisoft/assets']['assetManager']['register']);
            return $assetManager;
        },
        'reset' => function (ContainerInterface $container) {
            $this->registrar = new AssetRegistrar($container->get(Aliases::class), $container->get(AssetLoaderInterface::class));
        },
    ],
];
```

Start the Swoole HTTP server:

```
./yii swoole start
```

Start the Swoole HTTP server using the specified options:

```
./yii swoole start --address=127.0.0.1 --port=9501
```

Restart the Swoole HTTP server:

```
./yii swoole restart
```

[Restart](https://wiki.swoole.com/en/#/server/methods?id=reload) the Swoole HTTP server worker processes:

```
./yii swoole reload
```

Shutdown the Swoole HTTP server:

```
./yii swoole shutdown
```

### Configuring the Swoole HTTP server.

[](#configuring-the-swoole-http-server)

Add the Swoole HTTP server [settings](https://wiki.swoole.com/en/#/server/setting) to the `config/web/params.php` file and then restart the server:

Example:

```
return [
    // ...
    'klsoft/yii3-swoole' => [
        'swooleServerSettings' => [
             'log_file'   => __DIR__ . '/../../runtime/logs/swoole.log'
        ]
    ],
];
```

Enable SSL:

```
return [
    // ...
    'klsoft/yii3-swoole' => [
        'enableSwooleSsl' => true,
        'swooleServerSettings' => [
            'ssl_cert_file' => __DIR__ . '/../ssl/domain.crt',
            'ssl_key_file' => __DIR__ . '/../ssl/domain.key'
        ]
    ],
];
```

### Configuring the SwooleRequestHandlerInterface.

[](#configuring-the-swoolerequesthandlerinterface)

Configure your own version of the `SwooleRequestHandlerInterface` in the `config/web/di/application.php` file:

```
use Klsoft\Yii3Swoole\SwooleRequestHandlerInterface;
use Psr\Container\ContainerInterface;

return [
    // ...
    SwooleRequestHandlerInterface::class => static function (ContainerInterface $container) {
        return new MySwooleRequestHandler(
            // ...
        );
    }
];
```

### Use cron to start the Swoole HTTP server automatically.

[](#use-cron-to-start-the-swoole-http-server-automatically)

Edit the crontab file:

```
crontab -e
```

Add the following line:

```
@reboot path-to-app/yii swoole start --address=127.0.0.1 --port=9501
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance98

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

9d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4e8ac50e4ad22be84b07f4c06d28cf280d22f689c460cd385c556727e638827?d=identicon)[klsoft-web](/maintainers/klsoft-web)

---

Top Contributors

[![klsoft-web](https://avatars.githubusercontent.com/u/7967163?v=4)](https://github.com/klsoft-web "klsoft-web (2 commits)")

---

Tags

swooleyii3swooleyii3

### Embed Badge

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

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

###  Alternatives

[hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

3.9k686.6k13](/packages/hhxsv5-laravel-s)[swlib/saber

Swoole coroutine HTTP client

976148.4k28](/packages/swlib-saber)[yiisoft/app

Yii3 web application template

36813.9k](/packages/yiisoft-app)[simps/mqtt

MQTT Protocol Analysis and Coroutine Client for PHP

39455.7k11](/packages/simps-mqtt)[mezzio/mezzio-swoole

Swoole support for Mezzio

92247.8k3](/packages/mezzio-mezzio-swoole)[hyperf/http-server

A HTTP Server for Hyperf.

102.9M342](/packages/hyperf-http-server)

PHPackages © 2026

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