bear / swoole
Swoole script for BEAR.Sunday
Installs: 272
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/bear/swoole
Requires
- php: ^8.2
- ext-swoole: ^6.1
- bear/app-meta: ^1.6
- bear/query-repository: ^1.8.4
- bear/resource: ^1.31
- bear/sunday: ^1.6
- nyholm/psr7: ^1.8
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- ray/aop: ^2.18
- ray/di: ^2.14
- ray/input-query: ^1.0
- ray/psr-cache-module: ^1.3
- ray/psr7-module: ^1.4
- symfony/cache: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- bear/package: ^1.14
- bear/skeleton: ^1.10
- guzzlehttp/guzzle: ^7.5
- phpunit/phpunit: ^10.0 || ^11.0
- roave/security-advisories: dev-latest
- symfony/process: ^5.0 || ^6.0 || ^7.0
Suggests
- bear/query-repository: ^1.14 for ServerContextInterface support (coroutine-safe cache vary)
This package is auto-updated.
Last update: 2026-02-03 01:10:08 UTC
README
This library provides the support of Swoole into an BEAR.Sunday application.
Installation
Run the following to install this library:
composer require bear/swoole
Entry Script
Place the entry script file at bin/swoole.php with IP address and port number.
<?php require dirname(__DIR__) . '/autoload.php'; exit((require dirname(__DIR__) . '/vendor/bear/swoole/bootstrap.php')( 'prod-hal-app', // context 'MyVendor\MyProject', // application name '127.0.0.1', // IP 8080 // port ));
Execute
You can run a BEAR.Sunday application with Swoole using the following command:
php bin/swoole.php
Request Access
In Swoole's long-running process, PHP superglobals ($_SERVER, $_GET, $_POST, etc.) are not available per-request. Use PSR-7 ServerRequest injection instead:
use Psr\Http\Message\ServerRequestInterface; class MyResource extends ResourceObject { public function __construct( private ServerRequestInterface $request ) {} public function onGet(): static { $server = $this->request->getServerParams(); $query = $this->request->getQueryParams(); // ... } }