PHPackages                             wor/sockets - 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. wor/sockets

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

wor/sockets
===========

Sockets manager for for Laravel 5.5+

v1.0.2(7y ago)1482MITPHPPHP &gt;=7.0.1

Since Nov 2Pushed 7y agoCompare

[ Source](https://github.com/WindOfRussia/laravel-sockets)[ Packagist](https://packagist.org/packages/wor/sockets)[ RSS](/packages/wor-sockets/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

About laravel-sockets
=====================

[](#about-laravel-sockets)

This project is a good place to start for developing an application that is requires to retrieve or send data via UDP/TCP Sockets .

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

[](#requirements)

- PHP &gt;= 7.0
- Laravel &gt;= 5.5

Quick Install
-------------

[](#quick-install)

```
$ composer require wor/sockets:"^1.0"

```

OR

add `wor/sockets:"^1.0"` to your `require` list in the `composer.json` file.

#### Service Provider &amp; Facade (Optional on Laravel 5.5+)

[](#service-provider--facade-optional-on-laravel-55)

Register provider and facade on your config/app.php file.

```
'providers' => [
    ...,
    Wor\Sockets\SocketsServiceProvider::class,
]

'aliases' => [
    ...,
    'Sockets' => Wor\Sockets\SocketsFacade::class,
]

```

#### Configuration (Optional)

[](#configuration-optional)

```
$ php artisan vendor:publish --provider="Wor\Sockets\SocketsServiceProvider"

```

Debugging Mode
--------------

[](#debugging-mode)

To enable debugging mode, just set SOCKET\_DEBUG=true and the package will echo the raw payload being sent and received across Sockets.

IMPORTANT: Please make sure that SOCKET\_DEBUG is set to false when your app is on production.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

1. Add the default socket remote to your .env file

    ```
    ...
    SOCKET_CONNECTION=default
    SOCKET_HOST=
    SOCKET_PORT=
    SOCKET_PROTOCOL=tcp
    SOCKET_DEBUG=true
    ...

    ```
2. In Laravel or during a tinker session

    ```
    Sockets::write('Message');
    $response = Sockets::read(); //returns the string response from the socket.

    ```

### Intended Usage

[](#intended-usage)

This package is intended to be extended. There are two basic concepts at play here : Sockets &amp; Requests.

#### Sockets

[](#sockets)

Sockets are the basic communication layer. They should are meant to be extended to include any frame wrapping or encoding that you may want to use or that the receiving service expects.

They should extend the base Socket class and implement the SocketInterface.

In short you should implement the read &amp; write methods to match your expected I/O.

```
