cednore / boom-controller
Booming server control interface for Laravel
Requires
- php: ^7|^8
- guzzlehttp/guzzle: ^6.3
- laravel/framework: ^5.7|^6.0
Requires (Dev)
- phpunit/phpunit: ~6.0
README
Booming server control interface for Laravel
❗ IMPORTANT: This project is not actively maintained. |
---|
boom-controller
is a composer package for Laravel
applications to control boom-server
microservice.
See boom-demo
for example usage of this project.
Currently, this project supports only
socket.io:^2.2.0
,laravel:^5.7|^6.0
andphp:^7|^8
.
Features
- Expose endpoints to listen
socket.io
events coming from frontend clients - PHP class to provide same interface as
socket.io
's Node.js server (for easy porting of legacy applications) - Facade for smooth syntax
- Authentication of traffic between
boom-server
and API - State machine over MySQL table to share list of sockets
Installation
# Install cednore/boom-controller package composer require cednore/boom-controller # Create config, route and default controller for root namespace php artisan boom:init # Start development server php artisan serve
Emit cheatsheet (comparison between legacy JavaScript syntax and new PHP syntax)
Basic emit
socket.emit(/* ... */);
$request->socket->emit(/* ... */);
To all clients in the current namespace except the sender
socket.broadcast.emit(/* ... */);
$request->socket->broadcast->emit(/* ... */);
To all clients in room1 except the sender
socket.to('room1').emit(/* ... */);
$request->socket->to('room1')->emit(/* ... */);
To all clients in room1 and/or room2 except the sender
socket.to('room1').to('room2').emit(/* ... */);
$request->socket->to('room1')->to('room2')->emit(/* ... */);
To all clients in room1
io.in('room1').emit(/* ... */);
use Boom\Facades\Boom as IO; IO::in('room1')->emit(/* ... */);
To all clients in namespace "myNamespace"
io.of('myNamespace').emit(/* ... */);
use Boom\Facades\Boom as IO; IO::of('myNamespace')->emit(/* ... */);
To all clients in room1 in namespace "myNamespace"
io.of('myNamespace').to('room1').emit(/* ... */);
use Boom\Facades\Boom as IO; IO::of('myNamespace')->to('room1')->emit(/* ... */);
To individual socketid (private message)
io.to(socketId).emit(/* ... */);
use Boom\Facades\Boom as IO; IO::to($socketId)->emit(/* ... */);
To all clients on this node (when using multiple nodes)
io.local.emit(/* ... */);
use Boom\Facades\Boom as IO; IO::$local->emit(/* ... */);
To all connected clients
io.emit(/* ... */);
use Boom\Facades\Boom as IO; IO::emit(/* ... */);
Without compression
socket.compress(false).emit(/* ... */);
$request->socket->compress(false)->emit(/* ... */);
A message that might be dropped if the low-level transport is not writable
socket.volatile.emit(/* ... */);
$request->socket->volatile->emit(/* ... */);
Configuration
The file config/boom.php
contains an array of configurations. See code comments inside this file for detailed
explanations.
Artisan commands
Command: boom:init
Initialize boom controller.
Usage:
php artisan boom:init [options]
Options:
--force Overwrite any existing files.
Command: boom:make:nsp
Make a new socket.io namespace handler.
Usage:
php artisan boom:make:nsp [options] [--] <name>
Arguments:
name Name of new namespace to create.
Options:
--force Overwrite any existing files.
Cloning
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See Installation chapter for notes on how to use this project on a live system.
# Clone this repo git clone git@github.com:cednore/boom-controller.git cd boom-controller
Project roadmaps
- Testing desperately needed ;-)
- Resourceful documentation; Changelog, contribution guide, issue/PR templates, GitHub releases, dedicated documentation website
- Version compatibility check between
boom-controller
andboom-server
- CI/CD pipelines for building, testing and publishing
- Support higher
socket.io
andlaravel
versions - More smooth controller syntax
- Detailed error handling
- Memcached driver
- More stable db connection
- Dockerization of microservice
- Combine
boom-server
andboom-controller
in a single monorepo
License
This project is licensed under the MIT license. See full contents at LICENSE
file.