1. Go to this page and download the library: Download cloudfort/tez library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cloudfort / tez example snippets
use Cloudfort\Tez\TezClient;
$client = new TezClient(
endpoint: 'https://your-tez-server.example.com',
apiKey: 'your-api-key',
secret: 'your-base64-secret',
);
use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class OrderCreated implements ShouldBroadcast
{
use Dispatchable, SerializesModels;
public function __construct(public int $orderId) {}
public function broadcastOn(): array
{
return [new Channel('orders')];
}
public function broadcastAs(): string
{
return 'order.created';
}
public function broadcastWith(): array
{
return ['id' => $this->orderId];
}
}
event(new OrderCreated(42));
use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('orders.{orderId}', function ($user, int $orderId) {
return $user->canViewOrder($orderId);
});
Broadcast::channel('chat.{roomId}', function ($user, int $roomId) {
return ['name' => $user->name, 'avatar' => $user->avatar_url];
});