Download the PHP package gomoob/php-websocket-server without Composer

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

Gomoob WebSocket server

WebSocket server with tags management, forward messages on the right clients with ease !

Total Downloads Latest Stable Version Build Status Coverage Code Climate License

Introduction

The Gomoob WebSocket server is a simple Ratchet server which works with custom tags to easily forward messages to clients depending on custom tags.

As an example let's suppose we have a Web Application with English and French users. English users should receive English messages, French users should receive French messages.

Each application opens a Web Socket with a particular language tag.

On server side the Gomoob WebSocket server keeps track of the associations between tags and WebSocket connections. For example this simple PHP peace of code allows to easily forward a message to all clients connected with the language=FR tag.

Installation

Server side (run the server)

Running a server requires only one line of code.

Client side (PHP)

First pull the project with composer using the following dependency.

Then simply use the \Gomoob\WebSocket\Client\WebSocketClient class to send your messages.

If you want to write solid unit tests we also provide the \Gomoob\WebSocket\Client\WebSocketClientMock class. This class is a utility mock which is very easy to use.

Advanced configuration

The default behavior of the Gomoob WebSocket server is the following !

If one of those behaviors does not fit your need please read the following sub sections. You can also read the src/test/server.php file which shows how to start a server with custom message parsing and authorizations.

Message parser

By default the WebSocket server will accept plain string messages, if you try to send a JSON object then you'll encounter the following exception.

This is the expected behavior, if you want the server to manage custom PHP object messages then you have to :

A sample message object is provided in the \Gomoob\WebSocket\Message\Message class, feel free to read the associated source code to understand how it works. You'll also found a sample message parser in the \Gomoob\WebSocket\Message\MessageParser.

To explain how to manage custom PHP object messages let's suppose we have the following message object to send.

Sending such a message in a browser on Javascript would require the following code.

Or in PHP with the client we provide.

As this this will not work because on server side the Gomoob WebSocket server will not know how to parse the messages and how to re-create those messages to forward them to clients who opened WebSocket connections.

The first thing to do is to implement the \JsonSerializable class and the jsonSerializeMethod() in our MyMessage class.

Then we have to implement a message parser by extending the \Gomoob\WebSocket\IMessageParser class.

Finally we have to provide our parser when we create our WebSocket server.

Authorization Manager

By default the WebSocket server will accept all connections and message sendings, in most cases this behavior is not expected because anybody could open a WebSocket on your server and try to forward messages to all connected clients without authorization.

You can implement a custom authorization manager by implementing the \Gomoob\WebSocket\IAuthManager interface, this interface has the following signature.

So its very easy to manage authorizations, just return true or false with the authorizeOpen(...) or authorizeSend(...) functions.

The ApplicationsAuthManager

To easier authorization we provide an authorization manager which allows to declare several applications with key and secret properties.

This authorization manager is available in the \Gomoob\WebSocket\Auth\ApplicationsAuthManager class, it works with a very simple YAML configuration file.

Here is a sample instanciation of the manager with a WebSocket server.

The content of the auth.yml file could be the following.

Then the followig Javascript peace of code will apply.

The same rules are also applicable with the PHP client we provide.

Docker container

To help you start quickly we also provide a Docker container here https://hub.docker.com/r/gomoob/php-websocket-server.

Release history

1.2.0 (2016-08-23)

1.1.0 (2016-08-18)

1.0.3 (2016-08-17)

1.0.2 (2016-08-17)

1.0.1 (2016-08-17)

1.0.0 (2016-08-17)

About Gomoob

At Gomoob we build high quality software with awesome Open Source frameworks everyday. Would you like to start your next project with us? That's great! Give us a call or send us an email and we will get back to you as soon as possible !

You can contact us by email at [email protected] or by phone number (+33) 6 28 35 04 49.

Visit also http://gomoob.github.io to discover more Open Source softwares we develop.


All versions of php-websocket-server with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
cboden/ratchet Version ^0.3.5
monolog/monolog Version ^1.21.0
symfony/yaml Version ^3.1.3
textalk/websocket Version ^1.2.0
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 gomoob/php-websocket-server contains the following files

Loading the files please wait ....