Code Monkey home page Code Monkey logo

swoole-bundle's Introduction

Swoole Bundle

Maintainability Test Coverage Open Source Love MIT Licence

Symfony integration with Open Swoole to speed up your applications.

Sponsored by:
Blackfire.io Blackfire.io
Travis CI Travis CI

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 Open 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 swoole-bundle/swoole-bundle

    If using OpenSwoole, you need to also install the core package:

    composer require openswoole/core
  4. Edit config/bundles.php

    return [
        // ...other bundles
        SwooleBundle\SwooleBundle\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 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 (key swoole.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).

  • Access logs, (disabled by default) logs are configurable is a same way as apache mod log. Documentation of this feature is available here.

Requirements

Current version

  • PHP version >= 8.1 && <= 8.3
  • Open Swoole PHP Extension ^v22.1.2
  • Swoole PHP Extension ^5.1.1
  • Symfony ^5.4.22 || ^6.4

Future versions

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

Swoole

The bundle requires one of those extensions:

Version check

To check your installed version you can run the following command:

// Swoole
php -r "echo swoole_version() . \PHP_EOL;"

# 5.1.1

// OpenSwoole
php -r "echo OpenSwoole\Util::getVersion() . \PHP_EOL;"

# 22.0.0

Installation

Swoole

Official GitHub repository swoole/swoole-src contains comprehensive installation guide. The recommended approach is to install it from source.

OpenSwoole

Official GitHub repository openswoole/ext-openswoole contains comprehensive installation guide. The recommended approach is to install it from source.

swoole-bundle's People

Contributors

chadsikorra avatar coderchang65535 avatar dependabot-preview[bot] avatar dependabot[bot] avatar enumag avatar fjogeleit avatar jderusse avatar k911 avatar luca-nardelli avatar mab05k avatar pf-releaser-bot avatar rastusik avatar supersmile2009 avatar swoole-bundle-bot avatar symfony-swoole-bot avatar wirone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

pistej

swoole-bundle's Issues

SF 6.4 - there are no logs being shown in the symfony profiler

Since symfony 6.4 AddDebugLogProcessorPass dperecated function configureLogger and change debug_logger_configurator, so it seems DebugLogProcessorPass class from bundle is not correct/needed anymore.

MR with sf change: https://github.com/symfony/symfony/pull/52079/files#diff-e4f52d5033296421d02e360c8355aa1931bdfb0c12579f4815ea02b724322c0cL1179

https://symfony.com/doc/current/reference/configuration/kernel.html#kernel-runtime-mode

Simple fix can be remove class DebugLogProcessorPass and set sf. parameter: kernel.runtime_mode.web: true which is used as second param in DebugLoggerConfigurator

OnRequest event should wait until onWorkerStart finish

If HTTP request comes when onWorkerStart event is not finished yet, request is processed which is not desired. On request event should wait until start event finish, then start processing requests.

Idea, taken from hyperf fw: We can use Channel, size 1, onRequest call pop(), and wait until onWorkerStrart close the channel.

HELP migrating from K911 original package

I am migrating from the K911 original package that is not maintained anymore.

Server is starting but I get an error using BloomRPC (using GRPC).

I am using openswoole.

This is the error I get when I put level to debug:

TRACE Port_onRead_http() (ERRNO 7102): Bad Request: unknown protocol from session#3 on 0.0.0.0:50051

(I am running on port 50051).

I am not the original developer that setup grpc and swoole in the first place (they are not working in the company anymore).

If you have any idea to help me pin point the problem let me know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.