PHPackages                             codemash/laravel-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. codemash/laravel-socket

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

codemash/laravel-socket
=======================

A socket implementation for Laravel 5

1.0.0(9y ago)2618.0k6[7 issues](https://github.com/codemash/laravel-socket/issues)1MITPHP

Since Sep 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/codemash/laravel-socket)[ Packagist](https://packagist.org/packages/codemash/laravel-socket)[ RSS](/packages/codemash-laravel-socket/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (1)

Laravel Socket
==============

[](#laravel-socket)

This package allows you to use sockets easily and elegantly in your Laravel 5 application. Based on the awesome PHP socket library, [Ratchet](https://github.com/ratchetphp/Ratchet). Read the instructions below to get setup.

Requirements
------------

[](#requirements)

Laravel 5.x.

Installation
------------

[](#installation)

You can install the package using the [Composer](https://getcomposer.org/) package manager. You can install it by running this command in your project root:

```
composer require codemash/laravel-socket
```

Add the `Codemash\Socket\SocketServiceProvider` provider to the `providers` array in `config/app.php`':

```
'providers' => [
    ...
    Codemash\Socket\SocketServiceProvider::class,
],
```

Then, add the facade to your `aliases` array. The default facade provides an easy-to-use interface to integrate the socket files in your view.

```
'aliases' => [
    ...
    'Socket' => Codemash\Socket\Facades\Socket::class,
]
```

Finally, the config and the javascript files need to be published, which can be done by running the following command:

```
php artisan vendor:publish --provider="Codemash\Socket\SocketServiceProvider"
```

The published assets can be found at `config/socket.php` and the default javascript at `public/vendor/socket/socket.js`. It is important to know that the `Socket::javascript()` facade function will include both a default socket located at `window.appSocket` and the `socket.js` source file located in the vendor folder. These are merely a start, and provide a quick way to work with the sockets but you are always free to write a custom implementation.

Getting started
---------------

[](#getting-started)

Let's create a simple application that sends a message to all other connected clients. When a socket action occurs, it will be wrapped around a Laravel event and triggered. This is a great way for us to catch these events and act upon them. Let's register our listener in the `app/Providers/EventServiceProvider.php` file like this:

```
