Developed with love by KnpLabs Hire us for your project!
166

swoole-bundle

by k911

Symfony Swoole Bundle

Swoole Bundle

Maintainability
Test Coverage
Open Source Love
MIT Licence

Symfony integration with Swoole to speed up your applications.


Build Matrix

CI Job Branch master Branch develop
Circle CircleCI CircleCI
CodeCov codecov codecov
Travis Build Status Build Status

Table of Contents

Quick start guide

  1. Make sure you have installed proper Swoole PHP Extension and pass other requirements.

  2. (optional) Create a new symfony project

    composer create-project symfony/skeleton project
    
    cd ./project
    
  3. Install bundle in your Symfony application

    composer require k911/swoole-bundle
    
  4. Edit config/bundles.php

    return [
        // ...other bundles
        K911\Swoole\Bridge\Symfony\Bundle\SwooleBundle::class => ['all' => true],
    ];
    
  5. Run Swoole HTTP Server

    bin/console swoole:server:run
    
  6. Enter http://localhost:9501

  7. 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 (not yet 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.

  • Hot Module Reload (HMR) - for development

    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.

  • 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.

Requirements

  • PHP version >= 7.3.10
  • Swoole PHP Extension >= 4.4.7
  • Symfony >= 4.3.1

Additional requirements to enable specific features:

Swoole

Bundle requires Swoole PHP Extension version 4.4.7 or higher. Active bug fixes are provided only for the latest version.

Version check

To check your installed version you can run 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.

MIT License

Copyright (c) 2018 K911

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
  • chore(release): v0.8.0 :tada:
    By k911, 1 month ago
  • build(deps-dev): bump phpstan/phpstan-doctrine from 0.12.16 to 0.12.17 (#263)
    By web-flow, 1 month ago
  • chore(composer): upgrade deps (#262)
    By web-flow, 1 month ago
  • fix(profiler): make log collection in symfony profiler to work (#242)
    By web-flow, 1 month ago
  • refactor(error-handler): move to proper namespace (#251)
    By web-flow, 1 month ago
  • build(deps-dev): bump phpstan/phpstan-doctrine from 0.12.15 to 0.12.16 (#248)
    By web-flow, 1 month ago
  • build(deps-dev): bump phpstan/phpstan from 0.12.28 to 0.12.29 (#249)
    By web-flow, 1 month ago
  • feat(exception-handler): Add Symfony error/exception handler (#228)
    By web-flow, 1 month ago
  • feat(http-server): configurable mime types for advanced static files server (#240)
    By web-flow, 1 month ago
  • chore(composer): upgrade deps (#246)
    By web-flow, 1 month ago
  • fix(config): allow configuring worker and reactor counts using ENV variables (#244)
    By web-flow, 2 months ago
  • ci(circle): upgrade docker client image to v19.03.11 (#239)
    By web-flow, 2 months ago
  • chore(composer): add suggestion to use pixelfederation/doctrine-resettable-em-bundle to be able to recover from entity manager errors (#226)
    By web-flow, 2 months ago
  • build(deps-dev): bump doctrine/annotations from 1.10.2 to 1.10.3 (#223)
    By web-flow, 2 months ago
  • chore(deps): upgrade composer dependencies (#222)
    By web-flow, 2 months ago
  • feat(blackfire): Add bridge for upscale/swoole-blackfire (#221)
    By web-flow, 2 months ago
  • chore(release): v0.7.9 :tada:
    By k911, 2 months ago
  • fix(server): add worker_max_request and worker_max_request_grace configuration options (#220)
    By web-flow, 2 months ago
  • build(deps-dev): bump swoole/ide-helper from 4.4.17 to 4.5.0 (#197)
    By web-flow, 3 months ago
  • build(deps-dev): bump phpstan/phpstan from 0.12.19 to 0.12.20 (#212)
    By web-flow, 3 months ago
  • chore(release): v0.7.8 :tada:
    By k911, 3 months ago
  • chore(deps): upgrade ext-swoole to 4.5 (#209)
    By web-flow, 3 months ago
  • chore(release): v0.7.7 :tada:
    By k911, 3 months ago
  • ci(circle): use buildkit for building docker images (#208)
    By web-flow, 3 months ago
  • chore(composer): upgrade packages (#207)
    By web-flow, 3 months ago
  • test(phpunit): fix deprecations (#196)
    By web-flow, 3 months ago
  • build(deps-dev): bump phpunit/phpunit from 9.1.2 to 9.1.3 (#195)
    By web-flow, 3 months ago
  • build(deps-dev): bump doctrine/annotations from 1.10.1 to 1.10.2 (#194)
    By web-flow, 3 months ago
  • build(deps-dev): bump phpunit/phpunit from 9.1.1 to 9.1.2 (#193)
    By web-flow, 3 months ago
  • build(deps-dev): bump phpstan/phpstan from 0.12.18 to 0.12.19 (#192)
    By web-flow, 3 months ago