bearlord / yew-framework
A swoole distributed framework for network application
2.1
2026-09-21 13:09 UTC
Requires
- php: ^8.2
- ackintosh/ganesha: ^1.0|^2.0|^3.0
- cebe/markdown: ^1.2.1
- doctrine/annotations: ^1.6
- doctrine/cache: ^1.5
- doctrine/orm: ^2.5
- ezyang/htmlpurifier: ^4.10.0
- filp/whoops: ^2.3
- friendsofphp/consul-php-sdk: >=5.0.0
- guzzlehttp/guzzle: ^7.10.0
- illuminate/view: >=5.8
- inhere/php-validate: ^2.8
- jakubledl/dissect: ~1.0
- malkusch/lock: ^3.0
- monolog/monolog: ^1.24
- nikic/php-parser: ^5.7.0
- ocramius/proxy-manager: ^2.1
- opis/closure: ^3.6
- php-amqplib/php-amqplib: ^3.7.0
- php-di/php-di: ^7.1.0
- psr/http-message: ^1.0
- swlib/saber: ^1.0
- symfony/console: ^6.0
- symfony/finder: ^6.0
- symfony/var-dumper: *
- symfony/yaml: ^6.0.0
Requires (Dev)
- ext-iconv: *
- ext-json: *
- ext-libxml: *
- ext-pdo: *
- ext-posix: *
- ext-redis: *
- ext-sockets: *
- ext-swoole: >=5.1
- swoole/ide-helper: ^5.0
- symfony/process: ^6.0.0
- twig/twig: ^3.11.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A high-performance, Swoole-powered, plugin-oriented PHP application framework for building long-running, concurrent, multi-process services (MQTT brokers, WebSocket gateways, RPC servers, game/IM backends, etc.).
Why Yew
- Built on Swoole coroutines — millions of concurrent connections, native async I/O, no blocking.
- True multi-process model — Master / Manager / Worker / custom helper processes, each isolated, coordinated through shared memory tables and a typed IPC layer.
- Plugin-first architecture — every capability (Actor, Cluster, MQTT, Database, Redis, Queue, AOP, Route, Security …) is a plugin with a well-defined lifecycle and dependency ordering.
- Actor model — Akka-style actors with mailboxes, supervision, typed messages, routing (round-robin / consistent-hash / least-loaded) and optional event-sourcing.
- Clustering out of the box — Gossip membership, consistent-hash shard routing, location-transparent cross-node Actor transport, cluster-wide broadcast, and Actor replica / failover.
- MQTT server support — first-class MQTT 3.1.1/5.0 packet handling, subscription trees with
+/#wildcards, connection state in a dedicated helper process, and optional cross-node delivery. - Rich data layer — PDO connection pools, Redis pools (standalone/cluster/sentinel), Yii-style ActiveRecord, Redis-backed queue, and AMQP (RabbitMQ) producers/consumers.
- AOP & cross-cutting — source-transforming AOP (auth, rate-limit, circuit-breaker, routing, logging) plus scheduling, validation, session, JWT, and Snowflake ID generation.
Requirements
| Requirement | Version |
|---|---|
| PHP | >= 8.2 |
| Swoole | >= 5.1 (recommended >= 6.2; coroutine, async, table, process enabled) |
| Extensions | pdo, redis, bcmath (AMQP), inotify (optional, for hot reload) |
| Composer | >= 2.0 |
Quick Start
1. Install
composer require bearlord/yew-framework
2. Bootstrap (server.php)
<?php require __DIR__ . '/vendor/autoload.php'; use Yew\Framework\Application; $app = new Application(); $app->addPlugin(new \Yew\Plugins\Database\DatabasePlugin()); $app->addPlugin(new \Yew\Plugins\Redis\RedisPlugin()); $app->addPlugin(new \Yew\Plugins\Route\RoutePlugin()); $app->addPlugin(new \Yew\Plugins\Mqtt\MqttPlugin()); $app->addPlugin(new \Yew\Plugins\Mqtt\Connection\MqttConnectionPlugin()); $app->run(App\Application::class);
3. Configuration (resources/application.yml + profile)
yew: server: name: yew-app worker_num: 4 port: http: protocolType: http host: 0.0.0.0 port: 8080 mqtt: protocolType: mqtt host: 0.0.0.0 port: 1883 packTool: 'Yew\Plugins\Mqtt\MqttPack' logger: level: debug db: default: dsn: 'mysql:host=127.0.0.1;dbname=test' username: root password: root redis: default: host: 127.0.0.1 port: 6379
Config is loaded from
resources/application.ymlthen overlaid byresources/application-{profile}.yml(profile selected byyew.profiles.active). See Getting Started for the full mechanism.
4. Run
php server.php # start (debug mode) php server.php start -d # daemonize
Architecture at a Glance
┌───────────────────────────────────────────────┐
│ Swoole Server │
clients ─────▶├─ Master ─ Manager ─ Worker(s) ─ Helper(s) │
│ │ │ │
│ IPC ─────┴────────────┘ │
│ (typed, process-to-process) │
└───────────────────────────────────────────────┘
▲ ▲
Cluster gossip Cluster broadcast (UDP)
▲ ▲
Other Yew nodes ◀────────────┘
- Worker processes run your controllers, actors, and business logic.
- Helper processes host shared state (cluster-state, mqtt-connection, topic, multicast, queue …).
- IPC lets any process call typed methods on another process without blocking the event loop.
- Cluster (optional) links multiple nodes via Gossip + a dedicated UDP/TCP transport.
Documentation
| Section | English | 中文 |
|---|---|---|
| Getting Started | en-US | zh-CN |
| Actor model | en-US | zh-CN |
| Multicast (pub/sub) | en-US | zh-CN |
| AOP | en-US | zh-CN |
| Cluster | en-US | zh-CN |
| MQTT | en-US | zh-CN |
| Route | en-US | zh-CN |
| Pack | en-US | zh-CN |
| RPC & HTTP Client | en-US | zh-CN |
| Database | en-US | zh-CN |
| Redis | en-US | zh-CN |
| Queue | en-US | zh-CN |
| AMQP | en-US | zh-CN |
| Scheduled | en-US | zh-CN |
| Security & Session & Validate & JWT | en-US | zh-CN |
| Rate Limit & Circuit Breaker | en-US | zh-CN |
| Utilities (Uid, Topic, Connection, Console, AutoReload…) | en-US | zh-CN |
License
MIT © bearlord