PHPackages                             natilosir/telegram-bot-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. natilosir/telegram-bot-sdk

ActiveLibrary[API Development](/categories/api)

natilosir/telegram-bot-sdk
==========================

1.1.3(9mo ago)122MITPHPPHP &gt;=8.0

Since Jan 22Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/natilosir/Telegram-Bot-SDK)[ Packagist](https://packagist.org/packages/natilosir/telegram-bot-sdk)[ RSS](/packages/natilosir-telegram-bot-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (15)Used By (0)

Bot-SDK
=======

[](#bot-sdk)

A professional SDK for building Telegram Bots, designed with a Laravel-like structure for PHP.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- Composer

Installation
------------

[](#installation)

You can install this SDK package via Composer:

```
composer require natilosir/Telegram-Bot-SDK
php vendor/natilosir/bot/install.php
```

ORM
---

[](#orm)

For detailed documentation on the ORM, visit: [ORM Documentation](https://github.com/natilosir/ORM)

- [select](https://github.com/natilosir/ORM#select)
- [insert](https://github.com/natilosir/ORM#insert-array)
- [table](https://github.com/natilosir/ORM#select)
- [update](https://github.com/natilosir/ORM#update-array)
- [createOrFirst](https://github.com/natilosir/ORM#createorfirst)
- [createOrUpdate](https://github.com/natilosir/ORM#createorupdate)
- [delete](https://github.com/natilosir/ORM#delete)
- [eloquent](https://github.com/natilosir/ORM#update-model)
- [search](https://github.com/natilosir/ORM#search)
- [Count](https://github.com/natilosir/ORM#Count)
- [orderBy](https://github.com/natilosir/ORM#orderBy)
- [DISTINCT](https://github.com/natilosir/ORM#DISTINCT)
- [JSON](https://github.com/natilosir/ORM#JSON)
- [query](https://github.com/natilosir/ORM#query)
- [Model](https://github.com/natilosir/ORM#model)

Log::Class
----------

[](#logclass)

The `Log` class, along with global `lg()` and `dd()` functions in the `natilosir\bot` namespace, provides a robust logging system for PHP applications, particularly suited for debugging and monitoring in bot frameworks like Telegram bots.

### Features

[](#features)

#### AdvancedLogger Class

[](#advancedlogger-class)

- **HTML Log Output**: Generates a visually appealing HTML log file (`log.html`) with a responsive design and custom styles.
- **Multiple Log Levels**: Supports PHP error levels (e.g., `ERROR`, `WARNING`, `NOTICE`) and custom levels (`INFO`, `DEBUG`).
- **Error and Exception Handling**: Captures PHP errors, exceptions, and fatal errors using custom handlers.
- **Contextual Logging**: Allows adding context data to logs for additional debugging information.
- **Data Formatting**: Formats various data types (objects, arrays, strings, etc.) into readable HTML with color-coded styling.
- **Singleton Pattern**: Ensures a single logger instance to avoid duplicate log files or handlers.
- **Automatic Initialization**: Sets up error reporting, handlers, and log file creation automatically.

#### Log Class

[](#log-class)

- **Convenient Logging Methods**: Provides static methods (`info`, `debug`, `error`, `warning`, `notice`) for logging at specific levels.
- **Stack Trace Support**: Automatically captures the file and line number where the log is called.

#### Global Functions

[](#global-functions)

- **`lg()`**: A flexible function for logging data at any specified level with optional context, appending to the HTML log file.
- **`dd()`**: Logs data at the `DEBUG` level and terminates script execution, ideal for debugging.

### Usage

[](#usage)

The `AdvancedLogger` is initialized automatically with a default log file (`log.html`) and sets up error and exception handlers. The `Log` class and global `lg()` and `dd()` functions provide easy ways to log messages or debug data.

#### Example

[](#example)

```
