Download the PHP package ez-php/broadcast without Composer

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

ez-php/broadcast

Real-time event broadcasting for ez-php applications. Publish events to named channels via a pluggable driver (Null, Log, Array, Redis) and stream them to connected clients using Server-Sent Events (SSE).


Installation


Quick Start

Register the provider in provider/modules.php:

Add configuration to config/broadcast.php:

Publish an event from anywhere:


Broadcastable Events

Implement BroadcastableInterface to make any event class broadcastable:

Dispatch via the facade:


Drivers

Driver BROADCAST_DRIVER Description
Null null Silently discards all events (default)
Log log Writes a summary to a log file or via error_log()
Array array Stores events in memory — designed for testing
Redis redis Publishes to Redis Pub/Sub channels via ext-redis

Log Driver

When BROADCAST_LOG_PATH is empty, events are written via error_log().

Redis Driver

Publishes events to Redis Pub/Sub channels via PHP's ext-redis extension. Subscribers (SSE proxy, WebSocket gateway) must be running separately — Redis Pub/Sub is fire-and-forget.

Array Driver (for Testing)


Server-Sent Events (SSE)

Server-Sent Events are an HTTP wire format and live in ez-php/http since 2.0: EzPhp\Http\Sse\SseEvent and StreamedResponse::sse(). Return the response from a controller — it travels through middleware (auth, CORS) like any other response:

The 1.x SseStream / SseResponse classes and the $response->emit(); exit; pattern were removed: they bypassed middleware and terminate(). See ez-php/docs/upgrade-1.x-to-2.0.md.


Static Facade

Broadcast is a static facade backed by a Broadcaster singleton:

Method Description
Broadcast::event(BroadcastableInterface) Publish via broadcastOn(), broadcastAs(), broadcastWith()
Broadcast::to(string $channel, string $event, array $payload) Publish directly
Broadcast::setBroadcaster(Broadcaster) Wire the singleton (done by BroadcastServiceProvider)
Broadcast::resetBroadcaster() Reset to null — call in test tearDown()

Throws RuntimeException if called before setBroadcaster().


Custom Driver

Implement BroadcastDriverInterface to add a custom backend:

Bind it in a service provider:


Client-Side Usage (JavaScript)

The browser's built-in EventSource API consumes SSE streams with no extra library required.

Basic subscription

Authenticated streams

SSE uses standard HTTP — pass credentials via a cookie or a query-parameter token (headers are not configurable in the browser EventSource API):

On the PHP side, validate $_GET['token'] in the SSE controller before opening the stream.

Multiple event types on one connection


Exceptions

BroadcastException (extends RuntimeException) is the base exception for this package. Broadcast::event() / Broadcast::to() throw RuntimeException if called before the broadcaster is set.


All versions of broadcast with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ez-php/contracts Version ^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 ez-php/broadcast contains the following files

Loading the files please wait ...