eng-mmustafa/laravel-location-monitor
Composer 安装命令:
composer require eng-mmustafa/laravel-location-monitor
包简介
Laravel real-time gateway for Location Monitor Service using Redis Pub/Sub and Reverb
README 文档
README
A robust Laravel package that acts as a real-time gateway for the Location Monitor Service. It subscribes to Redis Pub/Sub events from the core engine and broadcasts them via Laravel Reverb to your frontend.
Features
- 🔌 Redis Pub/Sub Integration: Listens to real-time location events from the Node.js engine.
- 📡 Laravel Reverb Ready: Broadcasts events securely using Laravel's native broadcasting system.
- 🛡️ Event Driven: Maps infrastructure messages to clean Laravel Events (
LocationUpdated,StatusUpdated). - 🏗️ Architecturally Sound: Decouples the heavy location processing from your Laravel application.
Requirements
- PHP 8.2+
- Laravel 10.0+
- Redis
- Laravel Reverb (or any compatible broadcaster)
Installation
- Install the package via composer:
composer require eng-mmustafa/laravel-location-monitor
- Publish the configuration file:
php artisan vendor:publish --tag=location-monitor-config
- Configure your environment variables in
.env:
LOCATION_MONITOR_REDIS_CONNECTION=default LOCATION_MONITOR_PREFIX=location-monitor: LOCATION_MONITOR_CHANNEL=location-monitor:events
Usage
1. Start the Listener
The package includes an Artisan command to listen for Redis events. This should be run as a daemon (e.g., using Supervisor).
php artisan location-monitor:listen
2. Subscribe in Frontend (Laravel Echo)
The package broadcasts events to private channels named agent.{agentId}.
// Using Laravel Echo Echo.private(`agent.${agentId}`) .listen('.location.updated', (e) => { console.log('Location update:', e.location); console.log('Speed:', e.speed); }) .listen('.status.updated', (e) => { console.log('Status changed:', e.newStatus); });
3. Access Location Data Manually
You can use the Facade to access the current state of any agent from your controllers or services.
use LocationMonitor\Facades\LocationMonitor; // Get last known location $location = LocationMonitor::location($agentId); // Get agent status $status = LocationMonitor::status($agentId);
Architecture
This package is designed as a Gateway. It does not perform location calculations or geofencing logic; that is handled by the Node.js Location Monitor Service.
- Node.js Service publishes
location-monitor:eventsto Redis. - Laravel Listener (
location-monitor:listen) picks up the message. - Laravel Event (
LocationUpdated) is dispatched. - Laravel Reverb broadcasts the event to WebSocket clients.
Security
By default, the package defines a broadcast channel agent.{agentId}. You should ensure your routes/channels.php or BroadcastServiceProvider is configured to handle authentication if you need custom logic. The package registers a default callback that allows any authenticated user to listen.
License
The MIT License (MIT). Please see License File for more information.
eng-mmustafa/laravel-location-monitor 适用场景与选型建议
eng-mmustafa/laravel-location-monitor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 eng-mmustafa/laravel-location-monitor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eng-mmustafa/laravel-location-monitor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-13