Speed up Laravel with Open Swoole

Published:

There are several open source libraries built for Laravel and Swoole integration: Laravel Swoole, Laravel-S.

Swoole libraries for Laravel

Laravel Swoole:

https://github.com/swooletw/laravel-swoole

  • Run Laravel/Lumen application on top of Swoole.
  • Outstanding performance boosting up to 5x faster.
  • Sandbox mode to isolate app container.
  • Support running websocket server in Laravel.
  • Support Socket.io protocol.
  • Support Swoole table for cross-process data sharing.
  1. Install laravel swoole with composer:
composer require swooletw/laravel-swoole
  1. Register service provider in Laravel:
<?php
[
    'providers' => [
        SwooleTW\Http\LaravelServiceProvider::class,
    ],
]
  1. Publish laravel swoole configuration files in Laravel:
php artisan vendor:publish --tag=laravel-swoole
  1. Run your laravel applicaiton with Swoole:
php artisan swoole:http {start|stop|restart|reload|infos}
Laravel-S:

https://github.com/hhxsv5/laravel-s

  1. Install the laravel-s with composer:
composer require "hhxsv5/laravel-s:~3.0" -vvv
  1. Register service provider in Laravel:
<?php
[
    'providers' => [
        Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class,
    ],
]
  1. Publish LaravelS configuration files in Laravel:
php artisan laravels publish

Then update the default LaravelS configurations.

  1. Run your laravel application with Swoole:
php artisan laravels {start|stop|restart|reload}