Download the PHP package votong/websocket without Composer

On this page you can find all versions of the php package votong/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 websocket

Laravel WebSocket server

WebSocket server based on Ratchet. Built to be completely event driven so it can used in several different project without having to manipulate the base code.

Installation

Add require and repositories information in the projects composer.json file:

Now its time to run composer update in your terminal.

After the update is complete the service provider needs to be registered in app/config/app.php inside the providers array:

Server side configuration

Run the following command in the projects root folder to startup the WebSocket server. By default the server will be run on port 8080 but by adding --port=[number] at the end of the command it is possible to change to any desired port.

This will startup a deamon service that will estsblish the WebSocket server. To make sure that command is constantly running it is recommended to use Supervisord to supervice the deamon.

Client side listener

This service comes included with the nessesary JavaScripts. To include these into the projects assets folder run the following command.

After that add thins line into the template file.

To estalish a WebSocket client add the following code.

The avilible configurations are:

Messages can be sent through the socket as soon as the connection is established. The first parameter is a event name that will be sent to the backend as a tracing event for easyer filtering. The second parameter is the message and can contain a string or a JSON.

Messages that are sent back from the server to the client contains a JSON with two elements, origData and data. OrigData contains any data that have been sent as a message and the server has responded to and data contains the reponse data from the server.

Add Event Listensers to responed/listen to anything that happneds in the WebSocket.

Events that will be fired is:

Server side listener

The server needs to be able to respond to any new connections or messages that are sent by the client. This is done by Laravels event listener. This can be setup in different ways but to recommented way is to use events.php.

If events.php is not already in the 'app/' folder create the file and after that open up 'app/start/global.php' and make sure the follwoing line is in the end of the file.

All events that will be handled by the server should now be placed inside events.php:

$connection or $from (depending on the event) has the following functions.

The send function will send the message to the client. If an event or sessionId needs to be specified this must be done before the message is sent.


All versions of websocket with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
cboden/ratchet Version 0.3.*
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 votong/websocket contains the following files

Loading the files please wait ....