Download the PHP package romainrg/ratchet_client without Composer
On this page you can find all versions of the php package romainrg/ratchet_client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download romainrg/ratchet_client
More information about romainrg/ratchet_client
Files in romainrg/ratchet_client
Package ratchet_client
Short Description CodeIgniter library who allow you to make powerfull applications with realtime interactions by using Websocket technology
License GPL-3.0-or-later
Homepage https://github.com/romainrg/ratchet_client
Informations about the package ratchet_client
ratchet_client (CodeIgniter)
CodeIgniter library who allow you to make powerfull applications with realtime interactions by using Websocket technology and Ratchetphp (Socketo.me) 🚀🚀
:books: Dependencies
- PHP 5.6+
- CodeIgniter Framework (3.1.8+ recommanded)
- Composer
- PHP Socket extension enabled
:beginner: Installation
:arrow_right: Step 1 : Library installation by Composer
Just by running following command in the folder of your project :
Or by adding following lines to your composer.json
file :
Don't forget to include your autoload to CI config file :
:arrow_right: Step 2 : Create library config file in your project (Optional)
You have to create in your CI config folder located in ./application/config/ratchet_client.php
or the library will take his own config file based on host 0.0.0.0:8282
:arrow_right: Step 3 : Loading the library
You can add the following lines direclty in your Controller file or your MY_Controller global file
You'r almost done :heavy_check_mark:
Examples of use
:arrow_right: Create your first App
It's not very difficult, the library will do your job and much more !
-
Edit your CI controller
Welcome.php
with the following lines (this will be our server) -
Create CI controller
User.php
and add following lines - Edit your CI view
welcome_message.php
with following lines (again :stuck_out_tongue_winking_eye:)
Ok you just created your first app ! :heavy_check_mark: (easy with CTRL+C and CTRL+V)
:arrow_right: Run the Websocket server
If you wan't to check you'r work, you have to run the server. Open you'r command prompt then type the command bellow in you'r project folder :
If you see the message the message bellow, you are done (don't close your cmd) !
:arrow_right: Test the App
Open three pages of your project on following url with different IDs :
http://localhost/myproject/user/index/204
http://localhost/myproject/user/index/402
http://localhost/myproject/user/index/604
:heavy_exclamation_mark: In my example, recipient_id is defined by user_id, as you can see, it's the auth callback who defines recipient ids.
If you have something like that, everything is ok for you:
You can try is by typing and sending something in each page (see cmd for more logs).
Broadcast messages with your php App :boom: !
If you want to broadcast message with php script or something else you can use library like textalk/websocket (who is included in my composer.json as required library)
Note : The first message is mandatory and always here to perform authentication
Authentication & callbacks :recycle:
The library allow you to define some callbacks, here's an example :
- Auth type callback is called at first message posted from client.
- Event type callback is called on every message posted.
What about Docker :whale: ?
Easy to start with this command (php 7.1 used)
Bugs :bug: or feature :muscle:
Be free to open an issue or send pull request
To do :construction:
- Origin check
- WSS support
- Add app routing fonctionnality
- Websocket native library