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

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

takielias/codeigniter4-websocket
================================

Websocket using Ratchet Websocket technology for CodeIgniter 4

2.0(2y ago)883.0k↓25%28[11 issues](https://github.com/takielias/codeigniter4-websocket/issues)MITPHPPHP ^7.2|^8.0

Since May 31Pushed 2y ago8 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/64740296eea22f0e5668ad805b684a58c57f522327d69de572b5a4feac837950/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/takielias/codeigniter4-websocket)[![Total Downloads](https://camo.githubusercontent.com/e97cb36fc3ff921cc1992fd0f75238c14b11c9e1c353811753d80293247fe34a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/takielias/codeigniter4-websocket)[![Contributors](https://camo.githubusercontent.com/f964babc4616f23ebebef5fa9103fc8892108b30a2024f7504b655d90bfbe405/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/takielias/codeigniter4-websocket/graphs/contributors)[![Forks](https://camo.githubusercontent.com/6673a0473390f8d9e06f8856df890b23bd0d793be9346974fc5235487bd05535/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/takielias/codeigniter4-websocket/network/members)[![Stargazers](https://camo.githubusercontent.com/4f93f62cb32842c73ac014044e155820e9412bb1e5389e6676c1a8113fae6357/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/takielias/codeigniter4-websocket/stargazers)[![Issues](https://camo.githubusercontent.com/a13f32b10b9546faa5186b33084d15fbd8e091aad7951b5f20ac81cedbee083e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/takielias/codeigniter4-websocket/issues)[![MIT License](https://camo.githubusercontent.com/a73862addc8698d144905d8c7c1e8b95828ff6f23531b60c67c48f0a8d97d363/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f74616b69656c6961732f636f646569676e69746572342d776562736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/takielias/codeigniter4-websocket/blob/master/LICENSE.txt)[![LinkedIn](https://camo.githubusercontent.com/737807e0d19894612aa0ec4f81b4d4044034b9fbc425dfc88ca496e9eb98e535/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4c696e6b6564496e2d626c61636b2e7376673f7374796c653d666c61742d737175617265266c6f676f3d6c696e6b6564696e26636f6c6f72423d353535)](https://linkedin.com/in/takielias)

 [ ![Logo](https://user-images.githubusercontent.com/38932580/71325065-b6d05600-2511-11ea-9169-694185c48f8b.png) ](https://github.com/takielias/codeigniter4-websocket)

### CodeIgniter 4 WebSocket Library

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

[ ![takielias](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/takielias)

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

#### WebSocket Library for Codeigniter 3.x

[](#websocket-library-for-codeigniter-3x-httpsgithubcomtakieliascodeigniter-websocket)

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 takielias/codeigniter4-websocket @dev
```

### 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 Websocket start
```

**N.B** : Don't forget to add the following line in app/Config/Routes.php `app/Config/Routes.php`

```
$routes->setAutoRoute(true);
```

**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`

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

[](#authentication-and-callbacks)

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

`auth, event, close, citimer, roomjoin, roomleave, roomchat`

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

```
    public function start()
    {
        $ws = service('CodeigniterWebsocket');
        $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 CodeigniterWebsocker.php config file in Your config directory.

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

Roadmap
-------

[](#roadmap)

See the [open issues](https://github.com/takielias/codeigniter4-websocket/issues) for a list of proposed features (and known issues).

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)

Taki Elias - [@takiele](https://twitter.com/takiele) -  -

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)

Support on Buy Me A Coffee
--------------------------

[](#support-on-buy-me-a-coffee)

Hey dude! Help me out for a cup of ☕!

[ ![takielias](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/takielias)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Total

2

Last Release

858d ago

Major Versions

1.0 → 2.02024-01-03

PHP version history (2 changes)1.0PHP ^7.2

2.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad247d1f93a5e71551ddb8719214e25ebbc427726d50359e243b7f4f2aacbfc?d=identicon)[takielias](/maintainers/takielias)

---

Top Contributors

[![takielias](https://avatars.githubusercontent.com/u/38932580?v=4)](https://github.com/takielias "takielias (20 commits)")

---

Tags

codeigniter4real-timewebsocketcodeigniterwebsocketrealtimeRatchetPHP7php8PHP Librarycodeigniter4codeigniter websocket

### Embed Badge

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

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

###  Alternatives

[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.9M215](/packages/ratchet-pawl)[centrifugal/phpcent

PHP library to communicate with Centrifugo HTTP API

1822.3M4](/packages/centrifugal-phpcent)

PHPackages © 2026

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