Download the PHP package werkraum/websocket-provider without Composer

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

websocket_provider

Provides basic setup to run Ratchet WebSocket servers within TYPO3.

Currently only for *nix Systems

composer req werkraum/websocket-provider

typo3cms websocket:start

Routes and Components

Components

Implement the Ratchet interface Ratchet\MessageComponentInterface in your extension. This is going to be the entry point for your logic.

Mark your component as public to make use of the Symfony dependency injection within it. Tag your component with websocket.component to register it with the WebSocket provider.

Configuration/Services.yaml

Routes

Symfony Routes are used to provide multi-tenancy.

You may let your component implement the interface CustomRouteInterface. Return your custom route path with a leading slash (e.g. /socket.io/my_component).

The default route for Vendor\Extension\MyComponent is /Vendor_Extension_MyComponent

Be aware that the route of your WebSockets may be prefixed by whatever you have set for your webserver config. In my case this is often /socket.io. You can set this server-wide prefix in the settings. The prefix is then prepended to every component route, even third-party ones using this extension.

The Loop

In case you need periodic timer or want to handle signals you can implement the interface ConfigureLoopInterface. You'll get the loop as parameter. The signals SIGTERM and SIGINT are already registered to shut down the server.

Configuration

See ext_conf_template.txt for all configuration options.

Commands

Command Description
websocket:list Lists running websocket servers
websocket:routes Lists all configured routes
websocket:start Starts the websocket server
websocket:stop Stops the websocket server

Demo

Ratchet ships a simple echo component. You can register it via Symfony DI.

any Configuration/Services.yaml

Security

Authentication

The current frontend and backend user sessions are added to the connection as UserAspects. The ID of the connection is added as well.

Connections are not rejected when not authenticated. Additionally the authentication is only checked on opening a connection.

Rate limiting

A basic limiter is shipped and can be configured in the settings. More sophisticated rate limiting should probably be done by your webserver.

Server config

ext-json, ext-pcntl and ext-posix are required for the cli commands to check on the status of the server.

NGINX

Laravel has some good documentation on how to setup NGINX for WebSockets.

https://beyondco.de/docs/laravel-websockets/basic-usage/ssl#usage-with-a-reverse-proxy-like-nginx

DDEV

Open the port. Either via DDEV config web_extra_exposed_ports or a custom docker-compose file.

docker-compose.websockets.yaml

Port and the URL part /socket.io can be adjusted to your needs. I recommend setting the extension setting route_prefix to whatever you set as the URL part in your websocket config.

Below is the proxy pass config that needs to be added to the webserver config. This uses a custom URL part to distinguish between WebSocket and regular HTTP requests. This integrates well with existing webserver configuration for TYPO3. The Laravel documentation has a Nginx setup without the URL part.

Remember to remove the #ddev-generated line in the webserver config otherwise your changes will be overridden after restarting DDEV.

Apache

NGINX

Thanks

Lots of ideas and inspiration taken from https://freek.dev/1228-introducing-laravel-websockets-an-easy-to-use-websocket-server-implemented-in-php


All versions of websocket-provider with dependencies

PHP Build Version
Package Version
Requires typo3/cms-core Version ^10.4
cboden/ratchet Version ^0.4.4
ext-pcntl Version *
ext-posix Version *
ext-json Version *
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 werkraum/websocket-provider contains the following files

Loading the files please wait ....