PHPackages                             garveen/laravoole - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. garveen/laravoole

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

garveen/laravoole
=================

Get 10x performance for Laravel on Swoole or Workerman

0.5.1(9y ago)8834.9k129[23 issues](https://github.com/garveen/laravoole/issues)[1 PRs](https://github.com/garveen/laravoole/pulls)MITPHPPHP &gt;=5.5.16

Since Nov 29Pushed 8y ago50 watchersCompare

[ Source](https://github.com/garveen/laravoole)[ Packagist](https://packagist.org/packages/garveen/laravoole)[ RSS](/packages/garveen-laravoole/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (9)Versions (31)Used By (0)

Laravoole
=========

[](#laravoole)

Laravel on Swoole Or Workerman

10x faster than php-fpm

[![Latest Stable Version](https://camo.githubusercontent.com/cb31a21d12d79127958603c007d941b5c27886599e9e1f4d87d339ffcc6431e6/68747470733a2f2f706f7365722e707567782e6f72672f6761727665656e2f6c617261766f6f6c652f762f737461626c65)](https://packagist.org/packages/garveen/laravoole)[![Total Downloads](https://camo.githubusercontent.com/3d1e845a3dfb7200745febfb213c03d2ae83bce72830b45e49208758075d8927/68747470733a2f2f706f7365722e707567782e6f72672f6761727665656e2f6c617261766f6f6c652f646f776e6c6f616473)](https://packagist.org/packages/garveen/laravoole)[![Latest Unstable Version](https://camo.githubusercontent.com/58d6d583514ace5bd0bf0705a8ef7cb58e2d768264eb4bf5d60cfb2379ee37bf/68747470733a2f2f706f7365722e707567782e6f72672f6761727665656e2f6c617261766f6f6c652f762f756e737461626c65)](https://packagist.org/packages/garveen/laravoole)[![License](https://camo.githubusercontent.com/9f8027533d8ca489e1e2239d3e9fc2e3a125fddbe54ed924558ea7e7fd1d8cd9/68747470733a2f2f706f7365722e707567782e6f72672f6761727665656e2f6c617261766f6f6c652f6c6963656e7365)](https://packagist.org/packages/garveen/laravoole)[![Build Status](https://camo.githubusercontent.com/7eafcadcd96e24f9bdd71adb9608e45fee97109eb518cbdcb5e416ff7a9eace0/68747470733a2f2f7472617669732d63692e6f72672f6761727665656e2f6c617261766f6f6c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/garveen/laravoole)[![Code Coverage](https://camo.githubusercontent.com/7abbfbae7dfb40c789388509c6ee018591152ded35ceb8639511890f87126d36/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6761727665656e2f6c617261766f6f6c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/garveen/laravoole/?branch=master)

Depends On
----------

[](#depends-on)

  php&gt;=5.5.16   laravel/laravel^ 5.1 Suggests
--------

[](#suggests)

  php&gt;=7.0.0   ext-swoole&gt;=1.7.21   workerman/workerman&gt;=3.0 Install
-------

[](#install)

To get started, add laravoole to you composer.json file and run `composer update`:

```
"garveen/laravoole": "^0.5.0"

```

or just run shell command:

```
 composer require garveen/laravoole
```

Once composer done its job, you need to register Laravel service provider, in your config/app.php:

```
'providers' => [
    ...
    Laravoole\LaravooleServiceProvider::class,
],

```

**Notice: You should NOT use file session handler, because it is not stable at this environement. Use redis or other handler instead.**

Usage
-----

[](#usage)

```
php artisan laravoole [start | stop | reload | reload_task | restart | quit]
```

Migrations
----------

[](#migrations)

### Upgrade to 0.4

[](#upgrade-to-04)

Event names has changed:

- `laravoole.on_request` =&gt; `laravoole.requesting`
- `laravoole.on_requested` =&gt; `laravoole.requested`
- `laravoole.swoole.websocket.on_close` =&gt; `laravoole.swoole.websocket.closing`

Config
------

[](#config)

To generate `config/laravoole.php`:

```
php artisan vendor:publish --provider="Laravoole\LaravooleServiceProvider"
```

Most of things can be configured with `.env`, and you should use `LARAVOOLE_{UPPER_CASE}` format, for example,

```
[
    'base_config' => [
        'host' => '0.0.0.0',
    ]
]
```

is equals with

```
LARAVOOLE_HOST=0.0.0.0
```

Events
------

[](#events)

You can handle events by editing `EventServiceProvider`:

```
public function boot()
{
    parent::boot();
    \Event::listen('laravoole.requesting', function ($request) {
        \Log::info($request->segments());
    });
}
```

- `laravoole.requesting`(`Illuminate\Http\Request`)
- `laravoole.requested`(`Illuminate\Http\Request`, `Illuminate\Http\Response`)
- `laravoole.swoole.websocket.closing`(`Laravoole\Request`, int `$fd`)

base\_config
------------

[](#base_config)

This section configures laravoole itself.

### mode

[](#mode)

`SwooleHttp` uses swoole to response http requests

`SwooleFastCGI` uses swoole to response fastcgi requests (just like php-fpm)

`SwooleWebSocket` uses swoole to response websocket requests **AND** http requests

`WorkermanFastCGI` uses workerman to response fastcgi requests (just like php-fpm)

#### user defined wrappers

[](#user-defined-wrappers)

You can make a new wrapper implements `Laravoole\Wrapper\ServerInterface`, and put its full class name to `mode`.

### pid\_file

[](#pid_file)

Defines a file that will store the process ID of the main process.

### deal\_with\_public

[](#deal_with_public)

When using Http mode, you can turn on this option to let laravoole send static resources to clients. Use this ***ONLY*** when developing.

### host and port

[](#host-and-port)

Default `host` is `127.0.0.1`, and `port` is `9050`

handler\_config
---------------

[](#handler_config)

This section configures the backend, e.g. `swoole` or `workerman`.

### Swoole

[](#swoole)

As an example, if want to set worker\_num to 8, you can set `.env`:

```
 LARAVOOLE_WORKER_NUM=8
```

or set `config/laravoole.php`:

```
[
    'handler_config' => [
        'worker_num' => 8,
    ]
]
```

See Swoole's document:

[简体中文](http://wiki.swoole.com/wiki/page/274.html)

[English](https://cdn.rawgit.com/tchiotludo/swoole-ide-helper/dd73ce0dd949870daebbf3e8fee64361858422a1/docs/classes/swoole_server.html#method_set)

### Workerman

[](#workerman)

As an example, if want to set worker\_num to 8, you can set `.env`:

```
 LARAVOOLE_COUNT=8
```

or set `config/laravoole.php`:

```
[
    'handler_config' => [
        'count' => 8,
    ]
]
```

See Workerman's document:

[简体中文](http://doc3.workerman.net/worker-development/property.html)

[English](http://wiki.workerman.net/Workerman_documentation#Properties)

Websocket Usage
---------------

[](#websocket-usage)

### Subprotocols

[](#subprotocols)

See Mozilla's Document: [Writing WebSocket server](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#Subprotocols)

The default subprotocol is [jsonrpc](http://json-rpc.org/), but has some different: `params` is an object, and two more properties:

`status` as HTTP status code

`method` is the same as request's method

You can define your own subprotocol, by implements `Laravoole\WebsocketCodec\CodecInterface` and add to `config/laravoole.php`.

### Client Example:

[](#client-example)

```
>

WebSocket Test

p{word-wrap: break-word;}
tr:nth-child(odd){background-color: #ccc}
tr:nth-child(even){background-color: #eee}

WebSocket Test

    var wsUri = "ws://localhost:9050/websocket";
    var protocols = ['jsonrpc'];
    var output = document.getElementById("output");

    function send(message) {
        websocket.send(message);
        log('Sent', message);
    }

    function log(type, str) {
        str = str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(//g, '&gt;');
        output.insertAdjacentHTML('beforeend', '' + type + '' + htmlEscape(str) + '');
    }

    websocket = new WebSocket(wsUri, protocols);
    websocket.onopen = function(evt) {
        log('Status', "Connection opened");
        send(JSON.stringify({method: '/', params: {hello: 'world'},  id: 1}));
        setTimeout(function(){ websocket.close() },1000)
    };
    websocket.onclose = function(evt) { log('Status', "Connection closed") };
    websocket.onmessage = function(evt) { log('Received', evt.data) };
    websocket.onerror = function(evt) {  log('Error', evt.data) };

```

Work with nginx
---------------

[](#work-with-nginx)

```
server {
    listen       80;
    server_name  localhost;

    root /path/to/laravel/public;

    location / {
            try_files $uri $uri/ @laravoole;
            index  index.html index.htm index.php;
        }

    # http
    location @laravoole {
        proxy_set_header   Host $host:$server_port;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;

        proxy_pass http://127.0.0.1:9050;
    }

    # fastcgi
    location @laravoole {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9050;
    }

    # websocket
    # send close if there has not an upgrade header
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
    location /websocket {
        proxy_connect_timeout 7d;
        proxy_send_timeout 7d;
        proxy_read_timeout 7d;
        proxy_pass http://127.0.0.1:9050;
        proxy_http_version 1.1;
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}
```

License
=======

[](#license)

[MIT](LICENSE)

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Recently: every ~1 days

Total

25

Last Release

3298d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.5.9

0.1.9PHP &gt;=5.5.16

### Community

Maintainers

![](https://www.gravatar.com/avatar/a687a3547d7a47791211285809677987ad4caa38852c66fc244ec8547e73eb5c?d=identicon)[acabin](/maintainers/acabin)

---

Top Contributors

[![garveen](https://avatars.githubusercontent.com/u/3214266?v=4)](https://github.com/garveen "garveen (162 commits)")[![denghongcai](https://avatars.githubusercontent.com/u/1433247?v=4)](https://github.com/denghongcai "denghongcai (6 commits)")[![chekun](https://avatars.githubusercontent.com/u/1967804?v=4)](https://github.com/chekun "chekun (2 commits)")[![chxj1992](https://avatars.githubusercontent.com/u/1113743?v=4)](https://github.com/chxj1992 "chxj1992 (1 commits)")[![hhxsv5](https://avatars.githubusercontent.com/u/7278743?v=4)](https://github.com/hhxsv5 "hhxsv5 (1 commits)")[![XhinLiang](https://avatars.githubusercontent.com/u/10645929?v=4)](https://github.com/XhinLiang "XhinLiang (1 commits)")

---

Tags

laravelswooleworkerman

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/garveen-laravoole/health.svg)

```
[![Health](https://phpackages.com/badges/garveen-laravoole/health.svg)](https://phpackages.com/packages/garveen-laravoole)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
