Download the PHP package ljhsmileking/laravel-gateway-worker without Composer
On this page you can find all versions of the php package ljhsmileking/laravel-gateway-worker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ljhsmileking/laravel-gateway-worker
More information about ljhsmileking/laravel-gateway-worker
Files in ljhsmileking/laravel-gateway-worker
Package laravel-gateway-worker
Short Description GatewayWorker SDK for Laravel
License MIT
Informations about the package laravel-gateway-worker
中文
Laravel GatewayWorker
In order to use GatewayWorker more elegantly in Laravel, I developed this extension based on GatewayWorker to make it ready to use.
Installation
Configuration
Laravel
-
Register the ServiceProvider and Facade in
config/app.php
(For Laravel 5.5 and above, no manual registration is required) -
Publish the configuration file:
- Modify the corresponding configurations in
config/gateway-worker.php
located in the application root directory.
Lumen
Lumen has not been used or tested, the following instructions are based on other extension package development.
-
In
bootstrap/app.php
around line 82: - Publish the
config/gateway-worker.php
configuration file by copying it fromvendor/smileymrking/laravel-gateway-worker/config/gateway-worker.php
to theproject_root/config
directory.
The configuration file already has a default websocket service named 'push', you can adjust the relevant configurations accordingly, or directly proceed to the next step to start the service.
Starting the service
Use the following command to start the service:
php artisan gateway-worker {serviceName} {action} {--d}
Parameter | Description |
---|---|
serviceName | Service name, which is the key name in the configuration file. |
action | Action command, available commands are status , start , stop , restart , reload , connections . |
--d | Use DAEMON mode. |
'push' is the default service name that was created, you can synchronize the configuration file and modify the relevant configurations as needed.
Creating Multiple Services
You can start multiple services simultaneously.
Adding a new service
Directly copy a duplicate of the 'push' configuration file and make the necessary modifications, paying attention to updating the 'worker_name', 'gateway_name', and related port configurations to avoid duplication. The key used in the configuration will be the service name.
After completing the configuration modifications, use the php artisan gateway-worker demo start
command to start the service, where 'demo' is the key name you configured.
Custom Event Handler
When 'event_handler' is not configured, it will use the SmileyMrKing\GatewayWorker\GatewayWorker\GatewayWorkerEvents
class, which implements the static methods 'onMessage', 'onConnect', and 'onClose'. You can customize the 'event_handler' class by inheriting from SmileyMrKing\GatewayWorker\GatewayWorker\GatewayWorkerEvents
and overriding the relevant static methods.
The 'default_service' configuration specifies which service's registration address Gateway::$registerAddress will connect to by default.
Message Pushing
You can directly use the \GatewayWorker\Lib\Gateway
class in GatewayWorker. For specific usage, please refer to the GatewayWorker manual.
Viewing Logs
The logs and PID files are located in the vendor/smileymrking/laravel-gateway-worker/src/GatewayWorker/worker
directory. You can customize the log and PID paths using the pid_file
and log_file
settings in the configuration.
References
License
MIT
All versions of laravel-gateway-worker with dependencies
illuminate/support Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.18|^7.0|^8.0|^9.0|^10.0
workerman/gateway-worker Version ^3.0