承接 php-core/simple-telegram-log 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-core/simple-telegram-log

Composer 安装命令:

composer require php-core/simple-telegram-log

包简介

A simple Telegram logging helper for PHP

README 文档

README

A simple Telegram logging helper for PHP

Usage

composer require php-core/simple-telegram-log

Examples:

Using environment vars (short usage)

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__) . '/vendor/autoload.php';

TGLog::logMessage('Test message');

In code (flexible usage)

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__) . '/vendor/autoload.php';

TGLog::init(
    '123456:124334534534', // tg bot token
    -14943993494, // tg chat id
    null, // tg channel topic id
    false // debug mode
)->sendMessage('Test message');

Logging a PHP "Exception/Throwable"

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::logException(new Exception('Test exception'));

Log request dump

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::logRequestDump();

Debug log

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::debugLogMessage('This message will only be logged if debug mode is on');

Using custom Bot API

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::init(
    '123456:124334534534', // tg bot token
    -14943993494, // tg chat id
    null, // tg channel topic id
    false, // debug mode
    'https://tg-bot-api.php-core.com' // custom Bot API server url
)->sendMessage('Test message');

Using a cli program for HTTP requests (requires ability to run PHP's "exec" function and a cli program like "wget" installed)

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::init(
    '123456:124334534534', // tg bot token
    -14943993494, // tg chat id
    null, // tg channel topic id
    false, // debug mode
    TGLog::API_BASE_URL, // custom Bot API server url
    'wget' // (or "curl") the cli program to use for the HTTP request
)->sendMessage('Test message');

Using a cli program with nohup for HTTP requests (requires ability to run PHP's "exec" function and "nohup" as well as a cli program like "wget" installed)

use PHPCore\SimpleTelegramLog\TGLog;

require_once dirname(__DIR__).'/vendor/autoload.php';

TGLog::init(
    '123456:124334534534', // tg bot token
    -14943993494, // tg chat id
    null, // tg channel topic id
    false, // debug mode
    TGLog::API_BASE_URL, // custom Bot API server url
    'exec nohup setsid wget' // (or "curl") the cli program to use for the HTTP request
)->sendMessage('Test message');

Optional Environment Variables for simple use:

Variable Default Description
DEBUG false "true" or "false" enables or disables debug mode
TG_LOG_BOT_TOKEN x The default bot token to use for sending log messages
TG_LOG_CHAT_ID x The default chat ID to send log messages to
TG_LOG_TOPIC_ID x The default channel topic ID to send log messages to
TG_LOG_BOT_SERVER_URL https://api.telegram.org The base URL of the Bot API to use
TG_LOG_BOT_HTTP_CMD x Optional cli program to use in PHP's "exec" function for HTTP requests (e.g "curl" or "wget")

统计信息

  • 总下载量: 139
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-25