Download the PHP package kanata-php/conveyor-laravel-broadcaster without Composer
On this page you can find all versions of the php package kanata-php/conveyor-laravel-broadcaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kanata-php/conveyor-laravel-broadcaster
More information about kanata-php/conveyor-laravel-broadcaster
Files in kanata-php/conveyor-laravel-broadcaster
Package conveyor-laravel-broadcaster
Short Description Conveyor Laravel Broadcaster
License MIT
Informations about the package conveyor-laravel-broadcaster
Conveyor Laravel Broadcaster
This is a Laravel Integration for Socket Conveyor. It allows you to use the Conveyor WebSocket server as a broadcasting driver for Laravel. This package doesn't need Jacked Server, but just know that that web server is great!
This package allows the usage of Conveyor as a broadcasting driver in Laravel.
To understand how to broadcast with Laravel, visit Broadcasting.
Requirements
- PHP
^8.2 - Laravel 11 or 12
- A running Conveyor WebSocket server (see Extra)
The companion server package
kanata-php/socket-conveyordeclaresext-openswoole: ^22. This package overrides the platform requirement viaconfig.platformincomposer.json, so newer openswoole versions install cleanly without--ignore-platform-reqflags.
Quick Start
Table of Contents
- Step 1: Install the package via composer
- Step 2: Publish the configuration
- Step 3: Add Service Provider
- Step 4: Enable Laravel broadcasting
- Step 5: Add broadcasting config
- Step 6: Set configuration
- Step 7: Create the tokens table
- Step 8: Install the Conveyor JS Client
- Extra: Simple Conveyor Server for this example
Step 1: Install the package via composer
Step 2: Publish the configuration
Step 3: Add Service Provider
Laravel 10 backwards:
Laravel 11 onwards:
Step 4: Enable Laravel broadcasting
This is for Laravel 11 and forward, if in any other version just skip this step!
Step 5: Add broadcasting config
Add the following to your config/broadcasting.php file:
Step 6: Set configuration
Set the configurations for the WebSocket server in the .env file:
CONVEYOR_QUERYis the url query where we add the token you set to protect your WebSocket server.
Step 7: Create the tokens table
This package issues short-lived JWT tokens stored in a conveyor_tokens table. The package no longer ships a migration, so you must add one in your application:
Then in the generated migration:
Step 8: Install the Conveyor JS Client:
Important: Don't forget to run
npm run build!
Add this to the bootstrap.js file of your Laravel app so the Conveyor client is available globally:
Remember to run npm install and npm run dev or npm run prod to compile the assets.
Info: If you want to send one-off messages to the Conveyor WebSocket server, you can just dispatch an event like follows:
Important: notice that we are using
ShouldBroadcastNowinstead ofShouldBroadcast. Conveyor doesn't need queueing and is much faster this way. If you want, you can still use queues.
Example of usage in a view with authorization at this point:
Then, add the route for this view at your routes/web.php file:
Extra: Simple Conveyor Server for this example
You can use this simple server to test your broadcasting (and in production...):
Remember to install conveyor with composer require kanata-php/socket-conveyor and run the server with php server.php.
License
Released under the MIT License.