{"id":19020181,"url":"https://github.com/kanata-php/conveyor-laravel-broadcaster","last_synced_at":"2026-05-03T05:03:14.427Z","repository":{"id":213207569,"uuid":"629738073","full_name":"kanata-php/conveyor-laravel-broadcaster","owner":"kanata-php","description":"Conveyor Laravel Broadcaster","archived":false,"fork":false,"pushed_at":"2024-12-28T03:51:15.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-12T07:34:10.933Z","etag":null,"topics":["php","realtime","socket-io","websocket","websockets"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanata-php.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-18T23:40:41.000Z","updated_at":"2024-12-28T03:51:18.000Z","dependencies_parsed_at":"2024-04-27T20:28:08.148Z","dependency_job_id":"27adfff2-c110-45b7-a30a-be2d544c9d3d","html_url":"https://github.com/kanata-php/conveyor-laravel-broadcaster","commit_stats":null,"previous_names":["kanata-php/conveyor-laravel-broadcaster"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/kanata-php/conveyor-laravel-broadcaster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fconveyor-laravel-broadcaster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fconveyor-laravel-broadcaster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fconveyor-laravel-broadcaster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fconveyor-laravel-broadcaster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanata-php","download_url":"https://codeload.github.com/kanata-php/conveyor-laravel-broadcaster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fconveyor-laravel-broadcaster/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29128699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T18:31:02.507Z","status":"ssl_error","status_checked_at":"2026-02-05T18:29:43.962Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","realtime","socket-io","websocket","websockets"],"created_at":"2024-11-08T20:16:01.587Z","updated_at":"2026-05-03T05:03:14.420Z","avatar_url":"https://github.com/kanata-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Conveyor Laravel Broadcaster\n\nThis is a Laravel Integration for [**Socket Conveyor**](http://socketconveyor.com). It allows you to use the Conveyor WebSocket server as a broadcasting driver for Laravel. This package doesn't need [**Jacked Server**](https://github.com/jacked-php/jacked-server), but just know that that web server is great!\n\nThis package allows the usage of Conveyor as a broadcasting driver in Laravel.\n\n\u003e To understand how to broadcast with Laravel, visit [Broadcasting](https://laravel.com/docs/11.x/broadcasting).\n\n## Requirements\n\n- PHP `^8.2`\n- Laravel 11 or 12\n- A running Conveyor WebSocket server (see [Extra](#extra-simple-conveyor-server-for-this-example))\n\n\u003e The companion server package [`kanata-php/socket-conveyor`](https://packagist.org/packages/kanata-php/socket-conveyor) declares `ext-openswoole: ^22`. This package overrides the platform requirement via `config.platform` in `composer.json`, so newer openswoole versions install cleanly without `--ignore-platform-req` flags.\n\n## Quick Start\n\n**Table of Contents**\n\n- [Step 1: Install the package via composer](#step-1-install-the-package-via-composer)\n- [Step 2: Publish the configuration](#step-2-publish-the-configuration)\n- [Step 3: Add Service Provider](#step-3-add-service-provider)\n- [Step 4: Enable Laravel broadcasting](#step-4-enable-laravel-broadcasting)\n- [Step 5: Add broadcasting config](#step-5-add-broadcasting-config)\n- [Step 6: Set configuration](#step-6-set-configuration)\n- [Step 7: Create the tokens table](#step-7-create-the-tokens-table)\n- [Step 8: Install the Conveyor JS Client](#step-8-install-the-conveyor-js-client)\n- [Extra: Simple Conveyor Server for this example](#extra-simple-conveyor-server-for-this-example)\n\n#### Step 1: Install the package via composer\n\n```bash\ncomposer require kanata-php/conveyor-laravel-broadcaster\n```\n\n#### Step 2: Publish the configuration\n\n```bash\nphp artisan vendor:publish --provider=\"Kanata\\LaravelBroadcaster\\ConveyorServiceProvider\"\n```\n\n#### Step 3: Add Service Provider\n\nLaravel 10 backwards:\n\n```php\n\u003c?php\nreturn [\n    // ...\n    'providers' =\u003e [\n        // ...\n        Kanata\\LaravelBroadcaster\\ConveyorServiceProvider::class,\n    ],\n    // ...\n];\n```\n\nLaravel 11 onwards:\n\n```php\n\u003c?php\n\nreturn [\n    // ...\n    Kanata\\LaravelBroadcaster\\ConveyorServiceProvider::class,\n];\n```\n\n#### Step 4: Enable Laravel broadcasting\n\n\u003e This is for Laravel 11 and forward, if in any other version just skip this step!\n\n```shell\nphp artisan install:broadcasting --without-reverb --without-node\n```\n\n#### Step 5: Add broadcasting config\n\nAdd the following to your `config/broadcasting.php` file:\n\n```php\n\u003c?php\n\nreturn [\n    // ...\n    'conveyor' =\u003e [\n        'driver' =\u003e 'conveyor',\n        'protocol' =\u003e env('CONVEYOR_PROTOCOL', 'ws'),\n        'host' =\u003e env('CONVEYOR_URI', 'localhost'),\n        'port' =\u003e env('CONVEYOR_PORT', 8181),\n        'query' =\u003e env('CONVEYOR_QUERY', ''),\n    ],\n];\n```\n\n#### Step 6: Set configuration\n\nSet the configurations for the WebSocket server in the `.env` file:\n\n```dotenv\n# ...\nBROADCAST_CONNECTION=conveyor\n# ...\nCONVEYOR_URI=127.0.0.1\nCONVEYOR_PORT=8181\nCONVEYOR_QUERY=\"token=my-secure-conveyor-token\"\n# ...\n```\n\n\u003e `CONVEYOR_QUERY` is the url query where we add the token you set to protect your WebSocket server.\n\n#### Step 7: Create the tokens table\n\nThis 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:\n\n```bash\nphp artisan make:migration create_conveyor_tokens_table\n```\n\nThen in the generated migration:\n\n```php\n\u003c?php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration {\n    public function up(): void\n    {\n        Schema::create('conveyor_tokens', function (Blueprint $table) {\n            $table-\u003eid();\n            $table-\u003estring('name');\n            $table-\u003eforeignId('user_id');\n            $table-\u003estring('aud')-\u003enullable();\n            $table-\u003etext('token');\n            $table-\u003estring('aud_protocol')-\u003enullable();\n            $table-\u003einteger('allowed_uses')-\u003enullable();\n            $table-\u003einteger('uses')-\u003enullable();\n            $table-\u003edateTime('expire_at')-\u003enullable();\n            $table-\u003etimestamps();\n        });\n    }\n\n    public function down(): void\n    {\n        Schema::dropIfExists('conveyor_tokens');\n    }\n};\n```\n\n```bash\nphp artisan migrate\n```\n\n#### Step 8: Install the [Conveyor JS Client](https://www.npmjs.com/package/socket-conveyor-client):\n\n```bash\nnpm install socket-conveyor-client\n```\n\n\u003e Important: Don't forget to run `npm run build`!\n\nAdd this to the bootstrap.js file of your Laravel app so the Conveyor client is available globally:\n\n```js\nimport Conveyor from \"socket-conveyor-client\";\n\nwindow.Conveyor = Conveyor;\n```\n\nRemember to run `npm install` and `npm run dev` or `npm run prod` to compile the assets.\n\n\u003e **Info:** If you want to send one-off messages to the Conveyor WebSocket server, you can just dispatch an event like follows:\n\u003e ```php\n\u003e \u003c?php\n\u003e \n\u003e namespace App\\Events;\n\u003e \n\u003e use Illuminate\\Broadcasting\\InteractsWithBroadcasting;\n\u003e use Illuminate\\Broadcasting\\PrivateChannel;\n\u003e use Illuminate\\Contracts\\Broadcasting\\ShouldBroadcastNow;\n\u003e \n\u003e class TestEvent implements ShouldBroadcastNow\n\u003e {\n\u003e     use InteractsWithBroadcasting;\n\u003e \n\u003e     public function __construct(\n\u003e         public string $message,\n\u003e         public string $channel,\n\u003e     ) {\n\u003e         $this-\u003ebroadcastVia('conveyor');\n\u003e     }\n\u003e \n\u003e     public function broadcastOn(): array\n\u003e     {\n\u003e         return [\n\u003e             new PrivateChannel($this-\u003echannel),\n\u003e         ];\n\u003e     }\n\u003e }\n\u003e ```\n\u003e\n\u003e ```php\n\u003e event(new App\\Events\\TestEvent( message: 'my message', channel: 'my-channel'));\n\u003e ```\n\n\u003e **Important**: notice that we are using `ShouldBroadcastNow` instead of `ShouldBroadcast`. Conveyor doesn't need queueing and is much faster this way. If you want, you can still use queues.\n\n\nExample of usage in a view with authorization at this point:\n\n```html\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eWS Client\u003c/title\u003e\n    @vite(['resources/css/app.css', 'resources/js/app.js'])\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003ctextarea id=\"msg\"\u003e\u003c/textarea\u003e\n\u003cbutton id=\"btn-base\"\u003eBase\u003c/button\u003e\n\u003cbutton id=\"btn-broadcast\"\u003eBroadcast\u003c/button\u003e\n\u003cul id=\"output\"\u003e\u003c/ul\u003e\n\n\u003cscript type=\"text/javascript\"\u003e\n    // page elements\n    const msg = document.getElementById('msg')\n    const btnBase = document.getElementById('btn-base')\n    const btnBroadcast = document.getElementById('btn-broadcast')\n    const output = document.getElementById('output')\n\n    const connect = () =\u003e {\n        window.conveyor = new window.Conveyor({\n            protocol: '{{ $protocol }}',\n            uri: '{{ $uri }}',\n            port: {{ $wsPort }},\n            channel: '{{ $channel }}',\n            token: '{{ \\Kanata\\LaravelBroadcaster\\Conveyor::getToken($channel) }}',\n            onMessage: (e) =\u003e output.innerHTML = e,\n            onReady: () =\u003e {\n                btnBase.addEventListener('click', () =\u003e window.conveyor.send(msg.value))\n                btnBroadcast.addEventListener('click', () =\u003e window.conveyor.send(msg.value, 'broadcast-action'))\n            },\n        });\n    };\n\n    document.addEventListener(\"DOMContentLoaded\", () =\u003e connect());\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nThen, add the route for this view at your `routes/web.php` file:\n\n```php\nuse Illuminate\\Support\\Facades\\Route;\nuse Illuminate\\Support\\Facades\\Auth;\n\nRoute::get('/ws-client', function () {\n    Auth::loginUsingId(1); // here we authorize for the sake of the example.\n\n    return view('ws-client', [\n        'protocol' =\u003e config('broadcasting.connections.conveyor.protocol'),\n        'uri' =\u003e config('broadcasting.connections.conveyor.host'),\n        'wsPort' =\u003e config('broadcasting.connections.conveyor.port'),\n        'channel' =\u003e 'private-my-channel',\n    ]);\n});\n```\n\n#### Extra: Simple Conveyor Server for this example\n\nYou can use this simple server to test your broadcasting (and in production...):\n\n```php\n\u003c?php\n// file: server.php\n\ninclude __DIR__ . '/vendor/autoload.php';\n\nuse Conveyor\\ConveyorServer;\nuse Conveyor\\Events\\MessageReceivedEvent;\nuse Conveyor\\Events\\PreServerStartEvent;\n\n(new ConveyorServer())\n    // if you want to see messages in the console \n    -\u003eeventListeners([\n        Conveyor\\Constants::WEBSOCKET_SERVER_TOKEN =\u003e 'my-secure-conveyor-token',\n        Conveyor\\Constants::EVENT_MESSAGE_RECEIVED =\u003e function (MessageReceivedEvent $event) {\n            var_dump($event-\u003edata);\n        },\n    ])\n    -\u003eport(8181)\n    -\u003estart();\n```\n\nRemember to install conveyor with `composer require kanata-php/socket-conveyor` and run the server with `php server.php`.\n\n## License\n\nReleased under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanata-php%2Fconveyor-laravel-broadcaster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanata-php%2Fconveyor-laravel-broadcaster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanata-php%2Fconveyor-laravel-broadcaster/lists"}