https://github.com/true-async/yii3-spawn
Yii3 adapter for PHP TrueAsync — async HTTP server with coroutine-per-request isolation
https://github.com/true-async/yii3-spawn
Last synced: 2 days ago
JSON representation
Yii3 adapter for PHP TrueAsync — async HTTP server with coroutine-per-request isolation
- Host: GitHub
- URL: https://github.com/true-async/yii3-spawn
- Owner: true-async
- Created: 2026-05-21T05:58:13.000Z (26 days ago)
- Default Branch: main
- Last Pushed: 2026-05-21T06:20:14.000Z (26 days ago)
- Last Synced: 2026-05-21T13:05:30.137Z (25 days ago)
- Language: PHP
- Size: 41 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii3-spawn
Yii3 adapter for [PHP TrueAsync](https://github.com/true-async/php-async) — runs a Yii3
application on the [TrueAsync HTTP server](https://github.com/true-async/server) with
**coroutine-per-request isolation**.
> Status: **planning / WIP**. See [PLAN.md](PLAN.md) for the full design and roadmap.
## What it does
A standard Yii3 application is built once per worker. The TrueAsync server then handles
many HTTP requests **concurrently** inside that single worker — each request runs in its
own coroutine. `yii3-spawn` makes the stateful Yii3 singletons safe under that concurrency
by backing their per-request state with `Async\request_context()`, so application code
keeps working unchanged.
## Requirements
- PHP 8.6+ with the **TrueAsync** extension
- TrueAsync server extension (`TrueAsync\HttpServer`)
- Yii3 (`yiisoft/yii-http`, `yiisoft/di`, `yiisoft/yii-runner`)
## Installation
```bash
composer require true-async/yii3-spawn
```
## Running
Wire the runner into your Yii3 project's `public/index.php` (see
[`examples/index.php`](examples/index.php)):
```php
use TrueAsync\Yii3\Runtime\TrueAsyncRunner;
require_once dirname(__DIR__) . '/vendor/autoload.php';
(new TrueAsyncRunner(
rootPath: dirname(__DIR__),
serverOptions: ['host' => '0.0.0.0', 'port' => 8080, 'workers' => 1],
))->run();
```
`workers > 1` enables the TrueAsync server's built-in worker pool — no manual
thread spawning.
See [PLAN.md](PLAN.md) for architecture, the list of adapted components, and the
implementation roadmap.
## License
MIT