Download the PHP package flarum/realtime without Composer

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

Realtime provides a self-hosted alternative to Pusher with far more features and an active development roadmap. It offers realtime updates of activity on your forum, not just for members but also for guests.

Features

Requirements

Realtime contains a service you will need to install on your hosting environment, similar to the database service (MySQL) or web service (Apache, Nginx). As such you need your own virtual machine, droplet or an environment that allows you to configure scripts to run continuously. In addition, you will need to run a queue, we highly recommend the redis queue in combination with realtime.

For this reason this extension isn't likely applicable to anyone hosted on shared hosting environments.

Set up

Method a) use the defaults

No action needed. Your websocket will re-use the configuration of your existing forum.

Method b) the config.php

Create a key websocket and override any of the configuration items:

Configuration

All options:

Run the websocket server

For the websocket to run you will need to run its server. To do so for testing purposes, use:

This will boot the server and throw any debug information it can. This will keep the server running for as long as you keep this tab/window open.

The webservice will only run for as long as you keep your window open or your pc on using the above command. Using the realtime service in production requires setting it up as a daemon. See below for instructions for supervisor or systemd.

Daemon with supervisor

In production, you will need to set the websocket server to run continuously and restart when it errors. You can use a tool like supervisord for that.

Now create a new file inside the /etc/supervisor/conf.d directory called realtime.conf with:

Now read the configuration file and start the service:

Check whether the program is running:

More information about supervisor and its commands can be found in their documentation.

Daemon with systemd

Create a file with vim, vi or another editor of your choice at /etc/systemd/system/flarum-realtime.service with these contents:

Make sure to update the WorkingDirectory to match the directory where you installed Flarum. Update ExecStart to your version of php, you can use whereis php or whereis php80 to seek the path for each php version. Update the User to the user your site runs as.

Now reload the systemd service to pick up the service:

Start your service:

To understand whether it runs:

Now make sure to automatically start the service on reboots:

Auto restarting

The daemon will halt itself within 10 seconds when it identifies any change in your extensions. If you en- or disable an extension the daemon will stop. If properly set up this will allow the daemon to understand your Flarum changes and operate with the enabled extensions.

You can disable this feature by setting the --ignore-extension-toggles flag on the daemon:

Manually restarting

In case you want to force a restart within 10 seconds, for instance when using CI/CD, you can use the realtime:halt command:

Running encrypted

If you want to run the websocket server encrypted, the easiest way is to proxy the port with your webserver software (apache, nginx).

For nginx you can use the provided nginx configuration. Make sure to put the realtime nginx include before your flarum nginx include. Make sure to put both of these at the end of your server block:

We don't have examples for other webservers yet, but we'll gladly assist you with the installation on the Advanced edition.

Optional: to reduce overhead on your community from Flarum trying to interact with a remote url for sending realtime events, we can configure Flarum to use the current server as a target. To do so we can update our Flarum config.php like this:

FAQ

How many concurrent users does Realtime support? Resource usage of the websocket is really low. You should be able to serve thousands simultaneous users with only 1 cpu and 1 GB of memory dedicated to the process. Once we are able to provide a better indication from usage at scale, we will update this FAQ item. As a general rule of thumb it's always better to oversize your realtime daemon resource limitations and then - based on experience - reduce them to meet actual resource cost.

SendTriggerJob fails/is killed. In case the queue job SendTriggerJob fails every single time, make sure to increase the timeout of the queue worker. The default timeout is 60, also when you leave out the flag, so try running it with 360 like so: php flarum queue:work --timeout=360. Read the documentation of your queue driver to understand how to daemonize this command, for testing you can run it in your window with the additional -vvv flag for verbose logging.


All versions of realtime with dependencies

PHP Build Version
Package Version
Requires flarum/core Version ^2.0.0-rc.2
plesk/ratchetphp Version v1.0.4
pusher/pusher-php-server Version ^7.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 flarum/realtime contains the following files

Loading the files please wait ...