Download the PHP package belysh/laravel-socket-bridge without Composer

On this page you can find all versions of the php package belysh/laravel-socket-bridge. 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 laravel-socket-bridge

Tests Laravel 13 PHP 8.3+

Socket Bridge for Laravel

Send Laravel events and notifications over WebSockets, authorize subscriptions with channel policies, and handle client commands in PHP. A bundled NestJS / Socket.IO gateway manages connections; Redis Streams carry messages between the gateway and Laravel.

Each Laravel application runs its own bridge, with support for multiple gateway replicas.

Deployment

Requirements

Installation

The installer configures the socketio broadcaster and lets you choose how to run the gateway:

Start the gateway and workers alongside your Laravel HTTP server:

For native development with artisan serve, use socket-bridge:dev --serve to start Laravel as well. See the installation guide for Docker, Sail, Herd, Valet and HTTPS setup.

Broadcast an event

Create app/Events/OrderUpdated.php:

Authorize access in routes/channels.php. This example assumes the user has an orders relationship:

Dispatch the event from your application:

ShouldBroadcast sends through Laravel's queue, which socket-bridge:dev runs for you. Use ShouldBroadcastNow for immediate dispatch.

Receive it with Socket.IO

Connect to your gateway and request connection tickets from your Laravel API. Replace the example URLs with your own.

The example uses authHeaders from your application's existing login flow. With the default Laravel session authentication, include the current CSRF token as X-CSRF-TOKEN; for bearer authentication, use an Authorization header and configure the matching Laravel guard.

Each connection needs a fresh authentication ticket; the auth callback requests one on every attempt. The connect handler rejoins the channel after reconnect. Reload current application data after an interruption, since missed events are not replayed.

For a separate frontend origin, allow it in Laravel's CORS configuration and socket-bridge.gateway.origins. Cookie authentication also requires credentialed CORS requests and cookies configured for your frontend domain.

For long-lived connections, handle bridge.session and session:refresh as described in authentication examples for Sanctum.

Send a command to Laravel

Generate a handler:

Implement your business logic in the generated handler and register it in a service provider:

See the handler example for validation and authorization. Once connected, send the command using Socket.IO:

The acknowledgement contains the Laravel handler's result after processing through Redis Streams. To safely retry an unknown outcome, supply a command ID before the callback: socket.emit('order.pay', payload, { id: commandId }, callback). Reuse that ID and payload for retries. See acknowledgements and timeouts.

Send with the facade

Target a user or an authorized channel directly:

To persist an event together with a database change, use the transactional outbox:

The business update and outbox must use the same database connection. The outbox worker publishes the event to Redis and retries after failures.

Typing and other short-lived signals can expire before delivery:

Register short-lived incoming commands with ttlSeconds: 5 as the third argument to CommandRegistry::register(). Durable business events continue to use the transactional outbox. See delivery controls.

More ways to use the bridge

Task Guide
Exclude the sender with toOthers() HTTP request headers and channel authorization
Test application events with Socket::fake() Testing examples
Configure workers, health checks and maintenance Deployment
Run multiple gateway replicas Scaling
Understand retries, deduplication and recovery Delivery guarantees
Implement authentication, presence and recovery Socket.IO protocol reference
Check the complete Socket.IO → PHP → ACK path Roundtrip diagnostics
Review release test results Validation

Contributing

See SECURITY.md to report a vulnerability.

License

MIT.


All versions of laravel-socket-bridge with dependencies

PHP Build Version
Package Version
Requires illuminate/auth Version ^13.0
illuminate/broadcasting Version ^13.0
illuminate/console Version ^13.0
illuminate/database Version ^13.0
illuminate/http Version ^13.0
illuminate/redis Version ^13.0
illuminate/routing Version ^13.0
illuminate/support Version ^13.0
php Version ^8.3
symfony/process Version ^7.4 || ^8.0
symfony/yaml Version ^7.4 || ^8.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 belysh/laravel-socket-bridge contains the following files

Loading the files please wait ...