PHPackages                             daycry/websocket - 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. daycry/websocket

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

daycry/websocket
================

Websocket using Ratchet Websocket technology for CodeIgniter 4

v1.0.11(2y ago)31493MITPHPPHP ^7.3 || ^8.0

Since Jan 27Pushed 2y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (12)Used By (0)

### CodeIgniter 4 WebSocket Library

[](#codeigniter-4-websocket-library)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/donate?business=SYC5XDT23UZ5G&no_recurring=0&item_name=Thank+you%21&currency_code=EUR)

CodeIgniter WebSocket library. It allows you to make powerfull realtime applications by using Ratchet [Socketo.me](http://socketo.me) Websocket technology.

Table of Contents
-----------------

[](#table-of-contents)

- [Getting Started](#getting-started)
    - [Prerequisites](#prerequisites)
    - [Installation](#installation)
    - [Publishing](#publishing)
- [Usage](#usage)
    - [Authentication and callbacks](#authentication-and-callbacks)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Acknowledgements](#acknowledgements)

Getting Started
---------------

[](#getting-started)

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

### Prerequisites

[](#prerequisites)

- PHP 7.2+
- CodeIgniter Framework (4.\* recommended)
- Composer
- PHP sockets extension enabled

### Installation

[](#installation)

```
composer require daycry/websocket
```

### Publishing Resource

[](#publishing-resource)

You need to publish the resources for the default configuration

```
php spark websocket:publish
```

Usage
-----

[](#usage)

First start CodeIgniter

```
php spark serve
```

If you run the server in a different port, follow the command below.

```
PHP spark serve --port=9092
```

**Finally start Websocket Server**

```
php public/index.php chat start
```

**WOW You made it !!!** ✔️

Open two pages of your project on the following URL with different IDs :

**For default Port**`http://localhost:8080/Websocket/user/1``http://localhost:8080/Websocket/user/2`

**For custom Port**`http://localhost:9092/Websocket/user/1``http://localhost:9092/Websocket/user/2`

Broadcast messages with your php App
------------------------------------

[](#broadcast-messages-with-your-php-app)

If you want to broadcast message with php script or something else you can use library like [textalk/websocket](https://github.com/Textalk/websocket-php) ***(who is included in my composer.json as required library)***

```
$client = new \WebSocket\Client('ws://0.0.0.0:8282');

$client->send(json_encode(array('user_id' => 1, 'message' => null)));
$client->send(json_encode(array('user_id' => 1, 'message' => 'Super cool message to myself!')));
```

Authentication and callbacks
----------------------------

[](#authentication-and-callbacks)

There are few predefined callbacks, here's the list :

` auth, event, close, timer`

Please check Websocket.php controller To get the Defining example of various Callback Function

```
    public function start()
    {
        $ws = service('Websocket');
        $ws->set_callback('auth', array($this, '_auth'));
        $ws->set_callback('event', array($this, '_event'));
        $ws->run();
    }

    public function _auth($datas = null)
    {
        // Here you can verify everything you want to perform user login.

        return (!empty($datas->user_id)) ? $datas->user_id : false;
    }

    public function _event($datas = null)
    {
        // Here you can do everything you want, each time message is received
        echo 'Hey ! I\'m an EVENT callback' . PHP_EOL;
    }

```

Two Callback functions have been defined in the above example. First One is **auth** &amp; the Second one is **event**.

###### 🔨🔨🔨 If you need to customize Callback function, Please check the Websocket.php config file in Your config directory.

[](#-if-you-need-to-customize-callback-function-please-check-the-websocketphp-config-file-in-your-config-directory)

Contributing
------------

[](#contributing)

Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Contact
-------

[](#contact)

Daycry - [@daycry9](https://twitter.com/daycry9) -

Acknowledgements
----------------

[](#acknowledgements)

- [http://socketo.me](https://github.com/ratchetphp/Ratchet)
- [Websocket Client for PHP](https://github.com/Textalk/websocket-php)
- [Choose an Open Source License](https://choosealicense.com)
- [GitHub Pages](https://pages.github.com)
- [Animate.css](https://daneden.github.io/animate.css)
- [Loaders.css](https://connoratherton.com/loaders)
- [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
- [Font Awesome](https://fontawesome.com)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

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 ~65 days

Recently: every ~156 days

Total

11

Last Release

921d ago

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.0.10PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b0f66565d5c9ca3c84fb294e04f8d5e0b9a867d9c06f83b95bf168bd6fcf9bc?d=identicon)[daycry](/maintainers/daycry)

---

Top Contributors

[![daycry](https://avatars.githubusercontent.com/u/7590335?v=4)](https://github.com/daycry "daycry (17 commits)")

---

Tags

codeigniterwebsocketrealtimeRatchetPHP7PHP Librarycodeigniter4codeigniter websocket

### Embed Badge

![Health badge](/badges/daycry-websocket/health.svg)

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

###  Alternatives

[takielias/codeigniter4-websocket

Websocket using Ratchet Websocket technology for CodeIgniter 4

883.0k](/packages/takielias-codeigniter4-websocket)[takielias/codeigniter-websocket

CodeIgniter Websocket using Ratchet Websocket technology. Inspired by https://github.com/romainrg/ratchet\_client

609.1k](/packages/takielias-codeigniter-websocket)[cboden/ratchet

PHP WebSocket library

6.4k21.4M239](/packages/cboden-ratchet)[romainrg/ratchet_client

CodeIgniter library who allow you to make powerfull applications with realtime interactions by using Websocket technology

396.6k](/packages/romainrg-ratchet-client)[gos/web-socket-bundle

Symfony Web Socket Bundle

6202.2M8](/packages/gos-web-socket-bundle)[ratchet/pawl

Asynchronous WebSocket client

6148.9M214](/packages/ratchet-pawl)

PHPackages © 2026

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