PHPackages                             rubyqorn/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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. rubyqorn/socket

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

rubyqorn/socket
===============

Socket layer over PHP socket api

v1.0.1(5y ago)03MITPHPPHP ^8.0

Since Sep 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/rubyqorn/socket)[ Packagist](https://packagist.org/packages/rubyqorn/socket)[ Docs](https://github.com/rubyqorn/socket.git)[ RSS](/packages/rubyqorn-socket/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (0)

Socket
======

[](#socket)

This is a layer for client and server socket connections.
---------------------------------------------------------

[](#this-is-a-layer-for-client-and-server-socket-connections)

### PHP extension which have to be installed before to work:

[](#php-extension-which-have-to-be-installed-before-to-work)

- [PHP 8.0](https://www.php.net/downloads)
- [Yaml](https://www.php.net/manual/en/book.yaml.php)
- [Sockets](https://www.php.net/manual/en/book.sockets.php)

### Four actions you have to make:

[](#four-actions-you-have-to-make)

- Configure your configuration file.
- Create client.php or server.php file
- Call methods
- Run from CLI or extends

### Examples of TCP and UNIX sockets:

[](#examples-of-tcp-and-unix-sockets)

#### 1) Create configuration file. File can be **ONLY** with yaml(yml) or json extensions

[](#1-create-configuration-file-file-can-be-only-with-yamlyml-or-json-extensions)

##### \* TCP socket configuration using YAML

[](#-tcp-socket-configuration-using-yaml)

```
settings:
    socket_type: tcp
    address: 127.0.0.1
    port: 8000
    content_length: 2048

```

##### \* UNIX socket configuration using YAML

[](#-unix-socket-configuration-using-yaml)

```
settings:
    socket_type: unix
    address: socket.sock
    content_length: 2048

```

#### 2) Create client and server file handlers.

[](#2-create-client-and-server-file-handlers)

##### server.php

[](#serverphp)

```
