Download the PHP package freddie/mercure-x without Composer

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

Application Coverage

Freddie

Freddie is a PHP implementation of the Mercure Hub Specification.

It is blazing fast, built on the shoulders of giants:

See what features are covered and what aren't (yet) here.

Installation

PHP 8.1+ is required to run the hub.

As a standalone Mercure hub

This will start a Freddie instance on 127.0.0.1:8080, with anonymous subscriptions enabled.

You can publish updates to the hub by generating a valid JWT signed with the !ChangeMe! key with HMAC SHA256 algorithm.

To change these values, see Security.

As a bundle of your existing Symfony application

You can then start the hub by doing:

You can override relevant env vars in your .env.local and services in your config/services.yaml as usual.

Then, you can inject Freddie\Hub\HubInterface in your services so that you can call $hub->publish($update), or listening to dispatched updates in a CLI context 👍

Keep in mind this only works when using the Redis transport.

⚠️ Freddie uses its own routing/authentication system (because of async / event loop).

The controllers it exposes cannot be imported in your routes.yaml, and get out of your security.yaml scope.

Usage

It will start a new Mercure hub on 127.0.0.1:8080. To change this address, use the X_LISTEN environment variable:

Security

The default JWT key is !ChangeMe! with a HS256 signature.

You can set different values by changing the environment variables (in .env.local or at the OS level): X_LISTEN, JWT_SECRET_KEY, JWT_ALGORITHM, JWT_PUBLIC_KEY and JWT_PASSPHRASE (when using RS512 or ECDSA)

Please refer to the authorization section of the Mercure specification to authenticate as a publisher and/or a subscriber.

PHP Transport (default)

By default, the hub will run as a simple event-dispatcher, in a single PHP process.

It can fit common needs for a basic usage, but using this transport prevents scalability, as opening another process won't share the same event emitter.

It's still prefectly usable as soon as :

Redis transport

On the other hand, you can launch the hub on multiple ports and/or multiple servers with a Redis transport (as soon as they share the same Redis instance), and optionally use a load-balancer to distribute the traffic.

The official open-source version of the hub doesn't allow scaling because of concurrency restrictions on the bolt transport.

To launch the hub with the Redis transport, change the TRANSPORT_DSN environment variable:

Optional parameters you can pass in the DSN's query string:

Alternatively, you can set this variable into .env.local.

Advantages and limitations

This implementation does not provide SSL nor HTTP2 termination, so you'd better put a reverse proxy in front of it.

Example Nginx configuration

Example Caddy configuration

Single node

With multiple nodes

Payload limitations

⚠ There's a known limit in Framework-X which prevents request bodies to weigh more than 64 KB. At the time of writing, this limit cannot be raised due to Framework-X encapsulating HTTP Server instantiation.

Publishing bigger updates to Freddie (through HTTP, at least) could result in 400 errors.

Feature coverage

Feature Covered
JWT through Authorization header
JWT through mercureAuthorization Cookie
Allow anonymous subscribers
Alternate topics ✅️
Private updates
URI Templates for topics
HMAC SHA256 JWT signatures
RS512 JWT signatures
Environment variables configuration
Custom message IDs
Last event ID (including earliest) ✅️
Customizable event type ✅️
Customizable retry directive ✅️
CORS ❌ (configure them on your web server)
Health check endpoint ❌ (PR welcome)
Logging ❌ (PR welcome))️
Metrics ❌ (PR welcome)️
Different JWTs for subscribers / publishers ❌ (PR welcome)
Subscription API ❌️ (TODO)

Tests

This project is 100% covered with Pest tests.

Contribute

If you want to improve this project, feel free to submit PRs:

You can run the following command before committing to ensure all CI requirements are successfully met:

License

GNU General Public License v3.0.


All versions of mercure-x with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-ctype Version *
ext-iconv Version *
bentools/querystring Version ^1.1
clue/framework-x Version dev-main#cfe017426d8acc7a92b5893a501728e034a873cc
clue/redis-react Version ^2.5
doctrine/annotations Version ^1.0
lcobucci/jwt Version ^4.1
nyholm/dsn Version ^2.0
phpdocumentor/reflection-docblock Version ^5.3
react/async Version ^4.0.0
react/promise-timer Version ^1.10
rize/uri-template Version ^0.3.4
symfony/console Version ^5.4.0|^6.0.0
symfony/dotenv Version ^5.4.0|^6.0.0
symfony/flex Version ^1.17|^2
symfony/framework-bundle Version ^5.4.0|^6.0.0
symfony/options-resolver Version ^5.4.0|^6.0.0
symfony/property-access Version ^5.4.0|^6.0.0
symfony/property-info Version ^5.4.0|^6.0.0
symfony/runtime Version ^5.4.0|^6.0.0
symfony/serializer Version ^5.4.0|^6.0.0
symfony/uid Version ^5.4.0|^6.0.0
symfony/yaml Version ^5.4.0|^6.0.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 freddie/mercure-x contains the following files

Loading the files please wait ....