PHPackages                             rubikaphp/lib - 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. rubikaphp/lib

ActiveLibrary[API Development](/categories/api)

rubikaphp/lib
=============

PHP SDK for Rubika Bot API

472PHP

Since Mar 5Pushed 4mo agoCompare

[ Source](https://github.com/AbolfazlMirzae/RubikaPhp)[ Packagist](https://packagist.org/packages/rubikaphp/lib)[ RSS](/packages/rubikaphp-lib/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

RubikaPhp - Rubika Bot API SDK
==============================

[](#rubikaphp---rubika-bot-api-sdk)

A complete PHP SDK for building bots on **Rubika Messenger** using the official Rubika Bot API.

Features
--------

[](#features)

✅ **Complete API Coverage** - 48+ API methods
✅ **Advanced Button Types** - Calendar, Number/String Picker, Textbox, Location
✅ **Text Formatting** - Markdown formatting (Bold, Italic, Code, Links, Mentions)
✅ **Group Management** - User ban\\unban
✅ **Media Support** - Files
✅ **Flexible Updates** - Polling or Webhook modes
✅ **Type-Safe** - PHP 8.0+ with strong typing
✅ **Well Tested** - 100+ unit tests with 100% pass rate
✅ **PSR-4 Compliant** - Modern autoloading

\##installation:

```
git clone https://github.com/AbolfazlMirzae/RubikaPhp.git
cd RubikaPhp
composer install
```

Quick Start
-----------

[](#quick-start)

### Create a Bot

[](#create-a-bot)

```
use RubikaPhp\Core\Bot;

$bot = new Bot('YOUR_BOT_TOKEN');
```

### Send a Message

[](#send-a-message)

```
$bot->chatId('c12345')
    ->text('Hello from RubikaPhp!')
    ->sendMessage();
```

### Send a File

[](#send-a-file)

```
$bot->chatId('c12345')
    ->filePath('/path/to/file.pdf')
    ->sendFile();
```

### Handle Messages

[](#handle-messages)

```
use RubikaPhp\Filters\Filters;

$bot->onUpdate(Filters::text(), function($bot, $update) {
    $bot->chatId($update->new_message->chat_id)
        ->text('Echo: ' . $update->new_message->text)
        ->sendMessage();
});

$bot->run();
```

Advanced Features
-----------------

[](#advanced-features)

### Button Types

[](#button-types)

**Calendar Selection**

```
use RubikaPhp\Models\ButtonCalendar;
use RubikaPhp\Enums\ButtonCalendarTypeEnum;

$calendar = new ButtonCalendar(
    type: ButtonCalendarTypeEnum::DATEPERSIAN,
    min_year: '1400',
    max_year: '1410',
    title: 'Select Date'
);
```

**Number Picker**

```
use RubikaPhp\Models\ButtonNumberPicker;

$picker = new ButtonNumberPicker(
    min_value: '1',
    max_value: '100',
    title: 'Choose a number'
);
```

**Location Picker**

```
use RubikaPhp\Models\ButtonLocation;
use RubikaPhp\Models\Location;
use RubikaPhp\Enums\ButtonLocationTypeEnum;

$location = new ButtonLocation(
    type: ButtonLocationTypeEnum::PICKER,
    title: 'Share your location'
);
```

### Group Management

[](#group-management)

```
// Ban a user
$bot->banUser('group_chat_id', 'user_id');
// Unban a user
$bot->unbanUser('group_chat_id', 'user_id')
```

### Advanced Filters

[](#advanced-filters)

```
// Command filter
$bot->onUpdate(Filters::command('start'), $handler);

// Text with prefix
$bot->onUpdate(Filters::text('/help'), $handler);

// Combined filters
$bot->onUpdate(
    Filters::text()->and(Filters::isForwarded()),
    $handler
);

// File/Media filters
$bot->onUpdate(Filters::hasFile(), $handler);
$bot->onUpdate(Filters::hasLocation(), $handler);
$bot->onUpdate(Filters::hasSticker(), $handler);
```

### Text Formatting (Markdown)

[](#text-formatting-markdown)

```
use RubikaPhp\Utils\Markdown;

$text = "Bold
$bot->chatId('c123')->text($text)->sendMessage();
```

**Supported formats:**

- `Bold("**text**")` → **text**
- `Italic("__text__")` → \_text
- `Code("```php code```")` → `text`
- `Hyperlink("[text](link)")` → [text](url)
- `Mention("[text](guid)")` → [text](guid)
- `Spoiler("||text||")` → ||text||
- `Strike("~~text~~")` → text
- `Underline("--text--")` → --text--
- `Mono(``text``)` → `text`

Documentation
-------------

[](#documentation)

- [FEATURES.md](FEATURES.md) - Complete feature documentation
- [CHANGELOG.md](CHANGELOG.md) - Version history
- [examples/basic\_bot.php](examples/basic_bot.php) - Simple example
- [examples/advanced\_bot.php](examples/advanced_bot.php) - Advanced features
- [examples/webhook\_bot.php](examples/webhook_bot.php) - Webhook setup

Testing
-------

[](#testing)

Run the test suite:

```
./vendor/bin/phpunit tests/
```

Current status: **80/80 tests passing** ✅

API Methods
-----------

[](#api-methods)

### Message Operations

[](#message-operations)

- `sendMessage()` - Send text with optional keyboard
- `sendFile()` - Send file/document
- `sendPoll()` - Send poll/quiz
- `sendLocation()` - Send location
- `sendContact()` - Send contact info

### Message Editing

[](#message-editing)

- `editMessageText()` - Update message text
- `editMessageKeypad()` - Update inline keyboard
- `deleteMessage()` - Delete message
- `forwardMessage()` - Forward message

### Chat Info

[](#chat-info)

- `getMe()` - Get bot information
- `getChat()` - Get chat details

### Group Management

[](#group-management-1)

- `banUser()` - Ban user
- `unbanUser()` - Remove ban

### Bot Configuration

[](#bot-configuration)

- `setCommands()` - Set command list
- `updateBotEndpoints()` - Configure webhook
- `setEndpoint()` - Setup endpoint for all types
- `editChatKeypad()` - Update keyboard layout

### Updates

[](#updates)

- `getUpdates()` - Long polling
- `run()` - Start bot (polling or webhook)

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

[](#requirements)

- PHP &gt;= 8.0
- Composer
- cURL extension
- JSON extension
- GuzzleHttp 7.x

Structure
---------

[](#structure)

```
lib/
├── Core/Bot.php           # Main bot class
├── Api/RubikaAPI.php      # API client
├── Models/                # Data models
├── Filters/Filters.php    # Message filters
├── Enums/Enums.php        # Enumerations
└── Exceptions/            # Custom exceptions

```

Contributing
------------

[](#contributing)

Contributions welcome! Please follow PSR-12 standards and add tests for new features.

License
-------

[](#license)

MIT License - See LICENSE file

Support
-------

[](#support)

For API documentation, visit:

Version
-------

[](#version)

Current: **2.0.0**
Last Updated: 1404/12/3 Test Coverage: 100% (80/80 tests passing)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance52

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/223969936?v=4)[AbolfazlMirzae](/maintainers/AbolfazlMirzae)[@AbolfazlMirzae](https://github.com/AbolfazlMirzae)

---

Top Contributors

[![AbolfazlMirzae](https://avatars.githubusercontent.com/u/223969936?v=4)](https://github.com/AbolfazlMirzae "AbolfazlMirzae (13 commits)")

### Embed Badge

![Health badge](/badges/rubikaphp-lib/health.svg)

```
[![Health](https://phpackages.com/badges/rubikaphp-lib/health.svg)](https://phpackages.com/packages/rubikaphp-lib)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
