k911 / swoole-bundle
Swoole Symfony Bundle
Fund package maintenance!
k911
Installs: 77 700
Dependents: 0
Suggesters: 0
Security: 0
Stars: 250
Watchers: 11
Forks: 25
Open Issues: 28
Requires
- php: ^7.4|^8.0
- ext-json: *
- ext-swoole: ^4.5.10
- beberlei/assert: ^3.0
- symfony/config: ^4.3.1|^5.0
- symfony/console: ^4.3.1|^5.0
- symfony/dependency-injection: ^4.3.1|^5.0
- symfony/http-foundation: ^4.3.1|^5.0
- symfony/http-kernel: ^4.3.1|^5.0
- symfony/process: ^4.3.1|^5.0
Requires (Dev)
- doctrine/annotations: ^1.6
- doctrine/orm: ^2.6.3
- friendsofphp/php-cs-fixer: ^2.19.0
- jangregor/phpstan-prophecy: ^0.8.0
- phpspec/prophecy-phpunit: ^2.0
- phpstan/extension-installer: ^1.0.2
- phpstan/phpstan: ^0.12.28
- phpstan/phpstan-beberlei-assert: ^0.12.2
- phpstan/phpstan-doctrine: ^0.12.9
- phpstan/phpstan-phpunit: ^0.12.6
- phpunit/php-code-coverage: ^9.1.0
- phpunit/phpcov: ^8.1.0
- phpunit/phpunit: ^9.1.3
- swoole/ide-helper: ^4.5.10
- symfony/debug-pack: ^1.0
- symfony/error-handler: ^4.3.1|^5.0
- symfony/framework-bundle: ^4.3.1|^5.0
- symfony/messenger: ^4.3.1|^5.0
- symfony/monolog-bridge: ^4.3.1|^5.0
- symfony/monolog-bundle: ^3.3
- symfony/profiler-pack: ^1.0
- symfony/twig-bundle: ^4.3.1|^5.0
- symfony/var-dumper: ^4.3.1|^5.0
- symfony/yaml: ^4.3.1|^5.0
- upscale/swoole-blackfire: ^3.0
Suggests
- ext-inotify: To enable HMR
- doctrine/orm: For using Entity Manager Handler
- pixelfederation/doctrine-resettable-em-bundle: To be able to recover Doctrine Entity Managers from errors
- symfony/error-handler: To use Symfony Error Handler
- symfony/messenger: For using Symfony Messenger Swoole Task Transport.
- upscale/swoole-blackfire: To enable Blackfire profiling
- v0.10.0
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.0
- dev-dependabot/composer/develop/friendsofphp/php-cs-fixer-3.0.1
- dev-dependabot/composer/develop/phpstan/phpstan-0.12.94
- dev-dependabot/composer/develop/symfony/http-foundation-5.3.6
- dev-dependabot/composer/develop/symfony/console-5.3.6
- dev-dependabot/composer/develop/symfony/http-kernel-5.2.14
- dev-dependabot/composer/develop/symfony/dependency-injection-5.2.12
- dev-dependabot/composer/develop/symfony/config-5.3.4
- dev-dependabot/composer/develop/swoole/ide-helper-4.7.0
- dev-dependabot/composer/develop/phpstan/phpstan-phpunit-0.12.21
- dev-dependabot/composer/develop/doctrine/annotations-1.13.1
- dev-feat/signal-handling
- dev-master
- dev-dependabot/add-v2-config-file
- dev-feat/fsnotify-hmr
- dev-feat/dynamic-listeners
- dev-develop / 0.8.x-dev
This package is auto-updated.
Last update: 2022-02-03 06:04:32 UTC
README
Symfony integration with Swoole to speed up your applications.
Build Matrix
CI Job | Branch master |
Branch develop |
---|---|---|
Circle | ||
CodeCov | ||
Travis |
Table of Contents
Quick start guide
-
Make sure you have installed proper Swoole PHP Extension and pass other requirements.
-
(optional) Create a new symfony project
composer create-project symfony/skeleton project cd ./project
-
Install bundle in your Symfony application
composer require k911/swoole-bundle
-
Edit
config/bundles.php
return [ // ...other bundles K911\Swoole\Bridge\Symfony\Bundle\SwooleBundle::class => ['all' => true], ];
-
Run Swoole HTTP Server
bin/console swoole:server:run
-
Enter http://localhost:9501
-
You can now configure bundle according to your needs
Features
-
Built-in API Server
Swoole Bundle API Server allows managing Swoole HTTP Server in real-time.
- Reload worker processes
- Shutdown server
- Access metrics and settings
-
Improved static files serving
Swoole HTTP Server provides a default static files handler, but it lacks supporting many
Content-Types
. To overcome this issue, there is a configurable Advanced Static Files Server. Static files serving remains enabled by default in the development environment. Static files directory defaults to%kernel.project_dir%/public
. To configure your custom mime types check configuration reference (keyswoole.http_server.static.mime_types
). -
Symfony Messenger integration
Available since version:
0.6
Swoole Server Task Transport has been integrated into this bundle to allow easy execution of asynchronous actions. Documentation of this feature is available here.
-
Hot Module Reload (HMR) for development ALPHA
Since Swoole HTTP Server runs in Event Loop and does not flush memory between requests, to keep DX equal with normal servers, this bundle uses code replacement technique, using
inotify
PHP Extension to allow continuous development. It is enabled by default (when the extension is found) and requires no additional configuration. You can turn it off in bundle configuration.Remarks: This feature currently works only on a Linux host machine. It probably won't work with Docker, and it is possible that it works only with configuration:
swoole.http_server.running_mode: process
(default).
Requirements
Current version
- PHP version
>= 7.4
- Swoole PHP Extension
>= 4.5.10
- Symfony
>= 4.4.0
Future versions
- PHP version
>= 8.0
- Swoole PHP Extension
>= 4.6
- Symfony
>= 5.0
Additional requirements to enable specific features:
- Inotify PHP Extension
^2.0.0
to use Hot Module Reload (HMR)- When using PHP 8, inotify version
^3.0.0
is required
- When using PHP 8, inotify version
Swoole
Bundle requires Swoole PHP Extension version 4.5.10
or higher. Active bug fixes are provided only for the latest version.
Version check
To check your installed version you can run the following command:
php -r "echo swoole_version() . \PHP_EOL;" # 4.4.7
Installation
Official GitHub repository swoole/swoole-src contains comprehensive installation guide. The recommended approach is to install it from source.