imefisto / swoole-psr-kit
A PSR-compliant toolkit for building Swoole HTTP/WebSocket servers with dependency management
Requires
- php: ^8.1
- imefisto/psr-swoole-native: ^2
- league/route: ^6
- php-di/php-di: ^7.0
- psr/container: ^2.0
- psr/http-message: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2025-06-13 21:21:40 UTC
README
A PSR-compliant toolkit for building high-performance HTTP and WebSocket servers using Swoole with dependency management.
Features
- PSR-7 HTTP message interfaces
- PSR-15 middleware support
- PSR-11 container integration
- Named routes support via League Router
- WebSocket support
- Clean architecture structure
Installation
Install the package via Composer and require the PSR-7 implementation of your choice:
composer require imefisto/swoole-psr-kit composer require http-interop/http-factory-guzzle // or composer require nyholm/psr7
Usage
-
Run
php examples/basic/server.php
for a basic example. Test it withcurl localhost:8080/example
. -
Run
php examples/table/server.php
to run a version with Swoole table management. Add users withcurl localhost:8080/example -d user=some-user
andcurl localhost:8080/example
to get a list of the registered users. -
Run
php example/middleware/server.php
to see middlewares in action.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.