PHPackages                             yaro/socket - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. yaro/socket

ActiveLibrary[HTTP &amp; Networking](/categories/http)

yaro/socket
===========

simple websocket implementation for Laravel 4/5

1.0.1(10y ago)113599MITPHPPHP &gt;=5.4.0

Since Feb 15Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Cherry-Pie/websocket)[ Packagist](https://packagist.org/packages/yaro/socket)[ RSS](/packages/yaro-socket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Simple websocket server
-----------------------

[](#simple-websocket-server)

Fork of [morozovsk/websocket](https://github.com/morozovsk/websocket) for Laravel 4/5 integration.

### Installation

[](#installation)

```
composer require yaro/socket
```

Add to config/app.php:

```
'providers' => array(
//...
    Yaro\Socket\ServiceProvider::class,
//...
),
'aliases' => array(
//...
    'Socket' => Yaro\Socket\Facade::class,
//...
),
```

### Usage

[](#usage)

Sample command:

```
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class ChatCommand extends Command
{
    protected $name = 'socket:chat';

    protected $description = "chat command";

    public function fire()
    {
        Socket::init($this->argument('action'), array(
            'class' => 'ChatWebsocketDaemonHandler',
            'pid' => '/tmp/websocket_chat.pid',
            'websocket' => 'tcp://127.0.0.1:8000',
            //'localsocket' => 'tcp://127.0.0.1:8010',
            //'master' => 'tcp://127.0.0.1:8020',
            //'eventDriver' => 'event'
        ));
    } // end fire

    protected function getArguments()
    {
        return array(
            array('action', InputArgument::REQUIRED, 'start|stop|restart'),
        );
    } // end getArguments

    protected function getOptions()
    {
        return array();
    } // end getOptions
}
```

Sample handler class:

```
class ChatWebsocketDaemonHandler extends WebsocketDaemon
{
    protected function onOpen($connectionId, $info)
    {
    }

    protected function onClose($connectionId)
    {
    }

    protected function onMessage($connectionId, $data, $type)
    {
        if (!strlen($data)) {
            return;
        }

        $message = 'user #'. $connectionId .' ('. $this->pid .'): '. strip_tags($data);

        foreach ($this->clients as $idClient => $client) {
            $this->sendToClient($idClient, $message);
        }
    }
}
```

And run your command (command from example):

```
php artisan socket:chat
```

And your js on front will be like this:

```
var ws = new WebSocket("ws://127.0.0.1:8000/");
ws.onopen = function() {
    console.log('socket: open');
};
ws.onclose = function() {
    console.log('socket: close');
};
ws.onmessage = function(evt) {
    console.log(evt.data);
};
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~146 days

Total

3

Last Release

3818d ago

Major Versions

0.1 → 1.0.02015-11-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/337e05205184d845261f639b74255dedc7c3e75f069a38e79aa8083e91cf5a90?d=identicon)[Cherry Pie](/maintainers/Cherry%20Pie)

---

Top Contributors

[![Cherry-Pie](https://avatars.githubusercontent.com/u/3027596?v=4)](https://github.com/Cherry-Pie "Cherry-Pie (6 commits)")

---

Tags

laravelwebsocketSocketchat

### Embed Badge

![Health badge](/badges/yaro-socket/health.svg)

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

###  Alternatives

[morozovsk/websocket

simple php websocket server with examples and demo: simple chat (single daemon) - http://sharoid.ru/chat.html , pro chat (master + worker) - http://sharoid.ru/chat2.html , simple game - http://sharoid.ru/game.html

36417.3k2](/packages/morozovsk-websocket)[denis660/laravel-centrifugo

Centrifugo broadcaster for laravel

113164.7k](/packages/denis660-laravel-centrifugo)[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4983.9k](/packages/basement-chat-basement-chat)[morozovsk/yii2-websocket

simple php websocket server with examples and demo: simple chat (single daemon) - http://sharoid.ru/chat.html , pro chat (master + worker) - http://sharoid.ru/chat2.html , simple game - http://sharoid.ru/game.html

9414.8k](/packages/morozovsk-yii2-websocket)[morozovsk/websocket-examples

examples for simple php websocket server: simple chat (single daemon) - http://sharoid.ru/chat.html , pro chat (master + worker) - http://sharoid.ru/chat2.html , simple game - http://sharoid.ru/game.html

382.3k](/packages/morozovsk-websocket-examples)[sockeon/sockeon

Framework-agnostic PHP WebSocket and HTTP server library with attribute-based routing and support for namespaces and rooms.

291.3k2](/packages/sockeon-sockeon)

PHPackages © 2026

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