yireo / magento2-swoole-api
N/A
Package info
github.com/yireo/Yireo_SwooleApi
Type:magento2-module
pkg:composer/yireo/magento2-swoole-api
Requires
- php: >=8.2 <8.6
- ext-json: *
- ext-pcre: *
- ext-swoole: *
- laminas/laminas-http: ^2.15
- magento/framework: ^103.0.7
- magento/module-store: ^101.1.7
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- magento/module-webapi: ^100.4.7
- phpunit/phpunit: ^9.5 || ^10.5
- swoole/ide-helper: ^6.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-24 12:47:29 UTC
README
Current status: Experimental. If you are not contributing, support requests are not appreciated.
Forked from Swoolegento_Cli
This was forked from Swoolegento_Cli. PHP 8.3 has been added. Blackfire probing in the code has been removed. Upgrade commands to Symfony 6. Refactor main CLI command. Remove everything but support for GraphQL.
Installation
Make sure you have Swoole installed into PHP. Magento 2.4.7 or higher is required, because the server relies on the Magento state resetter to isolate requests from each other.
composer require yireo/magento2-swoole-api:@dev
bin/magento module:enable Yireo_SwooleApi
cp vendor/yireo/magento2-swoole-api/appserver.php .
php ./appserver.php
Configuration
The server is configured with environment variables:
| Variable | Default | Description |
|---|---|---|
SWOOLE_API_HOST |
127.0.0.1 |
IP address to listen on |
SWOOLE_API_PORT |
4000 |
Port to listen on |
SWOOLE_API_MAX_REQUEST |
500 |
Number of requests after which a worker is restarted |
SWOOLE_API_PACKAGE_MAX_LENGTH |
1048576 |
Maximum request size in bytes (1 KB to 64 MB) |
SWOOLE_API_TRUSTED_PROXIES |
127.0.0.1,::1 |
Comma-separated IPs of reverse proxies whose X-Forwarded-Proto header is trusted |
SWOOLE_API_DEBUG |
0 |
Log metadata (operation name, size, status, duration) of every request to var/log/swoole.log |
The server speaks plain HTTP. Do not expose it publicly: run it behind a reverse proxy (like Nginx) that terminates TLS and applies rate limiting.
Benchmarks
Original Magento GraphQL request (150ms-500ms):
time curl -S http://magento/graphql -H 'Content-Type: application/json' -d '{"query": "query {products {id}}"}'
Swoole GraphQL request with Swoole running on port 4000 (100ms-350ms):
time curl -S http://magento:4000/graphql -H 'Content-Type: application/json' -d '{"query": "query {products {id}}"}'