uitlaber/laravel-telegram-ray
Composer 安装命令:
composer require uitlaber/laravel-telegram-ray
包简介
A simple Laravel package to send ray() debug messages to Telegram.
README 文档
README
Laravel Telegram Ray
A simple and convenient Laravel package that adds a ray() helper function for sending debug information directly to your Telegram chat.
It’s a great alternative to Xdebug, dd(), or dump(), especially when working on a remote server or when you want to receive instant notifications.
## Features
-
Easy to use: Familiar
ray()function available anywhere in your Laravel application. -
Any data: Send strings, arrays, objects, collections, Eloquent models, and even exceptions.
-
Full context: Each message automatically includes:
- Project name
- Relative file path and line number where the function was called
- Full request URL, including all GET parameters
-
Flexible configuration: All settings are handled in the
.envfile. -
Easily disabled: You can enable or disable the function entirely with one
.envvariable, without changing your code.
## Installation
-
Install the package via Composer:
composer require uitlaber/laravel-telegram-ray
-
Publish the configuration file:
php artisan vendor:publish --provider="Uitlaber\LaravelTelegramRay\TelegramRayServiceProvider"This will create the file
config/telegram-ray.php.
## Configuration
Before using the package, you need to obtain your bot token and chat ID from Telegram.
- Bot token: Create a new bot using @BotFather in Telegram and copy the API token it provides.
- Chat ID: Open the @userinfobot in Telegram, start it, and it will send you your personal chat ID.
Now add these values and the ENABLE_RAY_TELEGRAM toggle to your .env file:
# .env # Enables (true) or disables (false) sending messages ENABLE_RAY_TELEGRAM=true # Your bot token from @BotFather TELEGRAM_BOT_TOKEN="YOUR:BOT_TOKEN" # Your chat ID from @userinfobot TELEGRAM_CHAT_ID="YOUR_CHAT_ID"
## Usage
You can call the ray() function anywhere in your Laravel application —
in routes, controllers, models, services, or even inside Blade templates (within @php ... @endphp).
Examples:
Send a simple message:
Route::get('/', function () { ray('User visited the homepage.'); return view('welcome'); });
Send an array or object:
use App\Models\User; $user = User::find(1); ray($user->toArray());
Send an exception:
try { // Code that might throw an error throw new \Exception('Something went wrong!'); } catch (\Exception $e) { ray($e); }
Example in Blade:
@php $data = ['product_id' => 123, 'status' => 'pending']; ray($data); @endphp <h1>Product Card</h1>
## Example Message in Telegram
Here’s how a debug message will appear in your Telegram chat:
🚀 Laravel 📄
routes/web.php:6📍[GET] http://sandbox.test/?data=1{ "id": 1, "name": "Damir", "email": "damir@example.com" }
## License
This package is open-source software licensed under the MIT license.
uitlaber/laravel-telegram-ray 适用场景与选型建议
uitlaber/laravel-telegram-ray 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 uitlaber/laravel-telegram-ray 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uitlaber/laravel-telegram-ray 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-15