Download the PHP package takielias/codeigniter-websocket without Composer

On this page you can find all versions of the php package takielias/codeigniter-websocket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package codeigniter-websocket

Latest Version on Packagist Total Downloads

takielias

CodeIgniter WebSocket Library

CodeIgniter WebSocket library. It allows you to make powerfull realtime applications by using Ratchet (Socketo.me & ratchet_client) Websocket technology.

WebSocket Library for Codeigniter 4.x https://github.com/takielias/codeigniter4-websocket

If you Face any problem you may check CodeIgniter WebSocket Example https://github.com/takielias/codeigniter-websocket-example

:books: Dependencies

:beginner: Installation

:arrow_right: Step 1 : Library installation by Composer

Just by running following command in the folder of your project :

Don't forget to include your autoload to CI config file :

:arrow_right: Step 2 : One command Setup

If you want Single command installation just Execute the Command in the Project directory

N.B: It will make 2 new controllers Welcome.php and User.php

Here app_path defines your default Codeigniter Application directory Name

one click installation

WOW You made it !!! :heavy_check_mark:

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

http://localhost/your project directory/index.php/user/index/1

http://localhost/your project directory/index.php/user/index/2

:heavy_exclamation_mark: In this 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:

user_1

user_2

You can try typing and sending something in each page (see cmd for more logs).

cmd

:arrow_right: Run the Websocket server Manually

If you want to enable debug mode 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) !

First_launch.png

:arrow_right: Test the App

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 :

How to receive response into Codeigniter Controller ?

Please look at the Welcome.php controller.

public function index()
{
    // Load package path
    $this->load->add_package_path(FCPATH . 'vendor/takielias/codeigniter-websocket');
    $this->load->library('Codeigniter_websocket');
    $this->load->remove_package_path(FCPATH . 'vendor/takielias/codeigniter-websocket');

    // Run server
    $this->codeigniter_websocket->set_callback('auth', array($this, '_auth'));
    $this->codeigniter_websocket->set_callback('event', array($this, '_event'));
    $this->codeigniter_websocket->set_callback('roomleave', array($this, '_roomleave'));
    $this->codeigniter_websocket->run();
}

public function _roomleave($data = null)
{
    // Here you will receive data from the frontend roomleave event trigger.
    echo 'Hey ! I\'m a room leave EVENT callback' . PHP_EOL;
}

The main concept is the callback function.

You would receive the response into the defined function. You can trigger the event from the front end like below using jQuery

    socket.send(JSON.stringify({
        'type': 'roomleave',
        'room_name': targetName,
        'user_id': "buzz4rd"
    }));

It would trigger the function below

public function _roomleave($data = null)
{
    // Here you will receive data from fron tend roomleave event trigger.
    echo 'Hey ! I\'m a room leave EVENT callback' . PHP_EOL;
}

You May Check Room Chat using PHP websocket. It was built using this

Bugs :bug: or feature :muscle:

Be free to open an issue or send pull request

Support on Buy Me A Coffee

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

takielias


All versions of codeigniter-websocket with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
cboden/ratchet Version ^0.4.1
textalk/websocket Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package takielias/codeigniter-websocket contains the following files

Loading the files please wait ....