Download the PHP package cloudfort/tez without Composer
On this page you can find all versions of the php package cloudfort/tez. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cloudfort/tez
More information about cloudfort/tez
Files in cloudfort/tez
Informations about the package tez
Tez — PHP SDK & Laravel Broadcaster
Tez is a PHP SDK and Laravel broadcaster for the Tez realtime broadcasting service. Publish events to channels, authenticate private and presence subscriptions, and integrate seamlessly with Laravel's broadcasting system.
Contents
- Installation
- Configuration
- Environment Variables
- Publishing the Config
- Standalone PHP SDK
- Creating a Client
- Publishing Events
- Creating Subscription Grants
- Laravel Integration
- Broadcast Driver Setup
- Broadcasting Events
- Channel Authentication
- Presence Channels
- Channel Types
- Protocol Constants
- Error Handling
- Testing
- License
Installation
Requirements: PHP 8.2+
For Laravel integration, the package auto-discovers its service provider. No manual registration needed.
Configuration
Environment Variables
Add these to your .env file:
| Variable | Description |
|---|---|
TEZ_ENDPOINT |
The base URL of your Tez server (scheme + host only, no path) |
TEZ_KEY |
Your API key (alphanumeric, plus ., _, :, -) |
TEZ_SECRET |
Your base64-encoded secret (must decode to at least 32 bytes) |
Publishing the Config
To customize the configuration file, publish it with:
This copies config/tez.php into your application's config/ directory.
Standalone PHP SDK
The SDK can be used without Laravel.
Creating a Client
Optional constructor parameters:
| Parameter | Type | Default | Purpose |
|---|---|---|---|
$http |
GuzzleHttp\ClientInterface |
Internal Guzzle client | Custom HTTP client |
$clock |
Closure(): int |
time() |
Injectable clock (useful for testing) |
$nonce |
Closure(): string |
bin2hex(random_bytes(16)) |
Injectable nonce generator |
Publishing Events
To exclude a specific socket (e.g., the sender's own connection):
Constraints:
- Up to 16 channels per publish
- Body must not exceed 65,536 bytes
- Channel names: 1-200 ASCII characters (
A-Za-z0-9._:-) - Event names: non-empty UTF-8, up to 200 bytes, no control characters
Creating Subscription Grants
Generate authentication tokens for private and presence channels:
Returns null for public channels (no authentication required).
Laravel Integration
Broadcast Driver Setup
In config/broadcasting.php, add a tez connection:
Then set the broadcast driver in your .env:
Broadcasting Events
Use Laravel's built-in broadcasting. Create an event that implements ShouldBroadcast:
Dispatch it as usual:
Channel Authentication
Tez handles authentication routes automatically through the TezBroadcaster. Register your channel authorization callbacks in routes/channels.php:
Presence Channels
For presence channels, return a non-empty array of user info from the channel callback:
The array is sent as user_info in the subscription grant. It must not exceed 1,024 bytes when JSON-encoded.
Channel Types
| Type | Prefix | Auth Required | Description |
|---|---|---|---|
| Public | (none) | No | Any client can subscribe |
| Private | private- |
Yes | Server-authorizes each subscription |
| Presence | presence- |
Yes | Private + tracks connected users with metadata |
Note: Encrypted channels (
private-encrypted-*) are not supported.
Protocol Constants
| Constant | Value | Description |
|---|---|---|
Protocol::MAX_CHANNELS |
16 | Max channels per publish call |
Protocol::MAX_BODY_BYTES |
65,536 | Max request body size |
Protocol::MAX_USER_INFO_BYTES |
1,024 | Max user info payload for presence |
Protocol::GRANT_TTL |
60s | Subscription grant time-to-live |
Protocol::PUBLISH_PATH |
/v1/channels/events |
API publish endpoint |
Error Handling
All server errors throw Cloudfort\Tez\Exceptions\TezException:
Validation errors throw InvalidArgumentException before any HTTP request is made.
Testing
Or directly:
License
The MIT License (MIT). See LICENSE for details.
All versions of tez with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/broadcasting Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0