hbsolutions / swoole-slim-app
Basis for REST API application on Slim 4 and Swoole Server.
dev-main
2022-11-28 17:39 UTC
Requires
- php: ^7.4||^8
- ext-json: *
- hbsolutions/php-helpers: 9999999-dev
- imefisto/psr-swoole-native: dev-master
- php-di/php-di: dev-master
- psr/simple-cache: ^1.0
- slim/psr7: dev-master
- slim/slim: 4.*
Requires (Dev)
- swoole/ide-helper: @dev
This package is auto-updated.
Last update: 2025-03-28 23:04:32 UTC
README
Basis for REST API application on Slim 4 and Swoole Server.
The library is in development so interfaces may change: do not use in production!
Installation
composer require hbsolutions/swoole-slim-app
Usage
App constructor takes the same parameters as PHP-DI's Container Builder method addDefinitions
.
use HBS\SwooleSlimApp\App; use Slim\App as SlimApp; use Swoole\WebSocket\Server; $swooleSlimApp = new App( 'path/to/your/php-di/definitions/config.php', [ 'some-definitions' => 'in-array', ] ); $swooleSlimApp->init( function (SlimApp $app) { // Add some Slim middleware here }, function (SlimApp $app) { // Add some Slim routes here }, [ App::OPTION_WITH_REQUEST_LOGGER => true, ] ); // Get Swoole Server and register some events if needed $swooleServer = $swooleSlimApp->getServer(); $swooleServer->on('start', function(Server $server) { echo "Swoole Server is started!\n"; }); // Start the Server $swooleSlimApp->startServer();
Demo project
See Demo project for more use cases.