Download the PHP package erfanvahabpour/bale-bot-sdk without Composer

On this page you can find all versions of the php package erfanvahabpour/bale-bot-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
erfanvahabpour/bale-bot-sdk
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package bale-bot-sdk

# 🤖 Bale Bot PHP SDK **The modern, feature-rich, and unofficial PHP SDK for the [Bale Messenger Bot API](https://docs.bale.ai/).** [![Tests](https://github.com/ErfanVahabpour/Bale-Bot-SDK/actions/workflows/ci.yml/badge.svg)](https://github.com/ErfanVahabpour/Bale-Bot-SDK/actions/workflows/ci.yml) [![Latest Version on Packagist](https://img.shields.io/packagist/v/erfanvahabpour/bale-bot-sdk.svg?style=flat-square&color=blue)](https://packagist.org/packages/erfanvahabpour/bale-bot-sdk) [![PHP Version](https://img.shields.io/badge/PHP-%5E8.2-777bb4.svg?style=flat-square&logo=php)](https://php.net) [![Laravel Support](https://img.shields.io/badge/Laravel-10%20%7C%2011%20%7C%2012%20%7C%2013-FF2D20.svg?style=flat-square&logo=laravel)](https://laravel.com) [![Software License](https://img.shields.io/badge/license-BSD--4--Clause-green.svg?style=flat-square)](LICENSE.md) [![Total Downloads](https://img.shields.io/packagist/dt/erfanvahabpour/bale-bot-sdk.svg?style=flat-square&color=orange)](https://packagist.org/packages/erfanvahabpour/bale-bot-sdk)
🌐 **Language / زبان:** **English** | [**فارسی (Persian)**](README.fa.md)

کتابخانه جامع و مدرن ساخت ربات پیام‌رسان بله برای PHP و لاراول (Laravel 10, 11, 12, 13)
Modern, strongly-typed PHP 8.2+ SDK for Bale Messenger Bot API with full support for Webhooks, Inline Keyboards, Media uploads, and In-App Payments.


🌟 Overview / معرفی

Bale Bot PHP SDK is an enterprise-grade, developer-friendly PHP library designed to seamlessly interact with the Bale Messenger Bot API. Whether you are building an e-commerce assistant, customer support bot, payment automation service, or interactive mini-app in Standalone PHP or Laravel, this SDK offers an expressive, robust, and strongly-typed toolkit.

[!NOTE] راهنمای فارسی / Persian Documentation:
اگر به دنبال ساخت ربات پیام‌رسان بله در زبان PHP یا فریم‌ورک لاراول (Laravel 10, 11, 12, 13) هستید، این کتابخانه کامل‌ترین SDK پی‌اچ‌پی برای وب‌سرویس بله است. تمامی قابلیت‌ها از جمله ارسال انواع پیام، دکمه‌های شیشه‌ای (Inline Keyboard)، وب‌هوک (Webhook)، درگاه پرداخت درون‌برنامه‌ای، آپلود رسانه و مدیریت چندین بات به طور کامل پیاده‌سازی شده‌اند. برای مطالعه راهنمای کامل به زبان فارسی به README.fa.md مراجعه فرمایید.


✨ Key Features


📖 Table of Contents


📋 Requirements

Requirement Minimum Version Notes
PHP >= 8.2 PHP 8.2, 8.3, 8.4+ supported
Laravel (Optional) ^10.0 \| ^11.0 \| ^12.0 \| ^13.0 For Laravel-based projects
Extensions ext-json, ext-curl, ext-mbstring Required PHP core extensions

📦 Installation

Install the package via Composer into your project:


🚀 Laravel Integration

1. Publish Configuration

The package registers EFive\Bale\Laravel\BaleServiceProvider and the Bale Facade automatically. Publish the configuration file:

This publishes config/bale.php into your Laravel application.

2. Configure Environment Variables

Add your bot token and optional parameters to your .env file:

3. Multi-Bot Configuration

Configure single or multiple bots in config/bale.php:

4. Artisan CLI Commands

Manage bot webhooks directly from the terminal:


🏁 Quick Start

In Standalone PHP

In Laravel


💡 Comprehensive Usage Guide

1. Sending & Managing Messages

Plain & Formatted Messages

Forwarding & Copying Messages

Editing & Deleting Messages


2. Interactive Keyboards & Mini-Apps

Inline Keyboards (Buttons attached to messages)

Reply Keyboards (Custom bottom input buttons)


3. Media & File Uploads

The SDK provides the flexible InputFile helper which supports local files, remote URLs, raw string contents, or open stream resources.

Downloading Files


4. Chat Actions & Typing Status

Send temporary chat status indicators (e.g. typing, uploading photo, recording video):


5. Chat, Group & Channel Administration

Manage chats, admins, bans, permissions, and invite links:


6. Webhooks & Polling Update Handling

Webhook Controller in Laravel

Define a webhook route in routes/api.php:

Long Polling in CLI Workers

For local development or daemon workers:


7. Command Bus & Custom Commands

The SDK includes a built-in Command Bus system. You can create organized Command classes that automatically resolve arguments, respond to updates, and leverage Laravel dependency injection.

Creating a Custom Command

Create a command class extending EFive\Bale\Commands\Command:

Registering & Processing Commands

In config/bale.php:

In your webhook route:


8. Bale In-App Payments & Invoices

Integrate digital sales and payments natively within Bale Messenger using the Bale Banking API:


9. Stickers & Custom Sticker Sets


10. Bot Commands Menu Management

Configure the command hints displayed to users in the Bale Messenger chat menu:


11. Event Dispatcher & Listeners

The SDK fires EFive\Bale\Events\UpdateWasReceived whenever an update is processed. In Laravel, you can register listeners in your EventServiceProvider:

In your listener:


12. Error & Exception Handling

The SDK provides structured exceptions for robust error handling:


13. Advanced Configuration & Custom Clients

Asynchronous Non-Blocking Requests

Enable async requests globally in .env (BALE_ASYNC_REQUESTS=true) or per instance:

Custom Base URL / API Proxy

For local mock servers or custom Bale reverse proxies:

Custom HTTP Client Handler

Implement EFive\Bale\HttpClients\HttpClientInterface to plug in your own HTTP transport client (e.g. customized cURL, Guzzle middleware stack, or HTTP/2 client).


📚 API Method Reference

All SDK methods return strongly-typed BaseObject models, arrays, or boolean statuses:

Category Method Parameters Return Type Description
Bot & Updates getMe [] User Get bot profile information
getUpdates ['offset'?, 'limit'?, 'timeout'?, ...] Update[] Poll for updates
setWebhook ['url', 'certificate'?, 'allowed_updates'?] bool Set webhook URL
deleteWebhook / removeWebhook [] bool Remove current webhook
getWebhookInfo [] WebhookInfo Get current webhook status
getWebhookUpdate [$shouldEmitEvents, $request] Update Parse incoming webhook update
Messaging sendMessage ['chat_id', 'text', 'reply_markup'?, ...] Message Send text message
forwardMessage ['chat_id', 'from_chat_id', 'message_id'] Message Forward existing message
copyMessage ['chat_id', 'from_chat_id', 'message_id', ...] MessageId Copy message without forward tag
editMessageText ['chat_id', 'message_id', 'text', ...] Message\|bool Edit message text
editMessageCaption ['chat_id', 'message_id', 'caption', ...] Message\|bool Edit media caption
editMessageReplyMarkup ['chat_id', 'message_id', 'reply_markup'] Message\|bool Edit inline keyboard markup
deleteMessage ['chat_id', 'message_id'] bool Delete message
sendChatAction ['chat_id', 'action'] bool Broadcast chat status (e.g. typing)
askReview ['chat_id', ...] Message Send review prompt
Media Uploads sendPhoto ['chat_id', 'photo', 'caption'?, ...] Message Send photo
sendAudio ['chat_id', 'audio', 'caption'?, ...] Message Send audio file
sendDocument ['chat_id', 'document', 'caption'?, ...] Message Send general file / document
sendVideo ['chat_id', 'video', 'caption'?, ...] Message Send video
sendAnimation ['chat_id', 'animation', 'caption'?, ...] Message Send animation / GIF
sendVoice ['chat_id', 'voice', 'caption'?, ...] Message Send voice audio message
sendMediaGroup ['chat_id', 'media'] Message[] Send photo/video album
sendLocation ['chat_id', 'latitude', 'longitude'] Message Send map location coordinates
sendContact ['chat_id', 'phone_number', 'first_name', ...] Message Send user vCard contact
getFile ['file_id'] File Retrieve file info
downloadFile ($file, $saveTo) string Download file to disk
Chat Management getChat ['chat_id'] ChatFullInfo Get chat details
getChatAdministrators ['chat_id'] ChatMember[] List chat administrators
getChatMembersCount ['chat_id'] int Get total chat member count
getChatMember ['chat_id', 'user_id'] ChatMember Get specific member info
banChatMember ['chat_id', 'user_id'] bool Ban user from chat
unbanChatMember ['chat_id', 'user_id'] bool Unban user in chat
promoteChatMember ['chat_id', 'user_id', ...] bool Promote member to admin
leaveChat ['chat_id'] bool Leave group or channel
setChatTitle ['chat_id', 'title'] bool Change chat title
setChatDescription ['chat_id', 'description'] bool Change chat description
setChatPhoto ['chat_id', 'photo'] bool Set new chat profile photo
deleteChatPhoto ['chat_id'] bool Delete chat profile photo
pinChatMessage ['chat_id', 'message_id', ...] bool Pin message in chat
unpinChatMessage ['chat_id', 'message_id'] bool Unpin message in chat
unpinAllChatMessages ['chat_id'] bool Unpin all messages
createChatInviteLink ['chat_id', 'expire_date'?, ...] string Create custom invite link
revokeChatInviteLink ['chat_id', 'invite_link'] string Revoke invite link
exportChatInviteLink ['chat_id'] string Export primary invite link
Interactions answerCallbackQuery ['callback_query_id', 'text'?, ...] bool Respond to inline button click
In-App Payments sendInvoice ['chat_id', 'title', 'prices', ...] Message Send payment invoice
createInvoiceLink ['title', 'prices', 'provider_token', ...] string Generate invoice payment link
answerPreCheckoutQuery ['pre_checkout_query_id', 'ok', ...] bool Approve/reject checkout
inquireTransaction ['payment_charge_id'] Transaction Check payment transaction state
Bot Commands setMyCommands ['commands'] bool Set bot commands list
getMyCommands [] BotCommand[] Retrieve registered bot commands
deleteMyCommands [] bool Delete registered bot commands
Stickers sendSticker ['chat_id', 'sticker'] Message Send sticker
uploadStickerFile ['user_id', 'sticker', 'sticker_format'] File Upload sticker file
createNewStickerSet ['user_id', 'name', 'title', 'stickers', ...] bool Create custom sticker set
addStickerToSet ['user_id', 'name', 'sticker'] bool Add sticker to existing set

❓ Frequently Asked Questions (FAQ) / سوالات متداول

1. How do I get a Bale Bot API Token? / چگونه توکن ربات بله دریافت کنم؟
To create a bot and get an API token: 1. Open the [Bale Messenger](https://bale.ai/) app. 2. Search for the official **`@BotFather`** account and start a conversation. 3. Send the command `/newbot` and follow the on-screen instructions to select a display name and a unique username ending with `bot`. 4. BotFather will provide an authorization token formatted like `123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ`. 5. Set this token in your `.env` file as `BALE_BOT_TOKEN=your_token_here`.
2. How to build a Bale bot in Laravel? / چگونه در لاراول ربات بله بسازیم؟
Install the package via Composer and publish the configuration: Add your bot token to `.env`: You can now use the `Bale` Facade anywhere in your Laravel application (Controllers, Jobs, Commands, or Routes):
3. Webhook vs Long-Polling: Which update mechanism should I use? / تفاوت وب‌هوک (Webhook) و پولینگ (Polling) چیست؟
- **Webhook (Recommended for Production)**: Bale servers push updates to your secure HTTPS webhook URL via POST requests in real time. It is high-performance, asynchronous, and scalable: - **Long-Polling (Ideal for Local Development & Testing)**: Your application polls Bale servers periodically for new messages. No public domain, static IP, or SSL certificate is required. Run:
4. How to create Inline Keyboards (Glass Buttons) with callback queries? / نحوه ساخت دکمه شیشه‌ای (Inline Keyboard) در ربات بله چیست؟
Inline keyboards are attached directly under messages. You can pass URLs, callback data, or mini-app WebApp triggers: Handle button clicks in your webhook or controller by inspecting `$update->getCallbackQuery()`, and acknowledge them using `Bale::answerCallbackQuery(['callback_query_id' => $id])`.
5. How does Bale In-App Payment work? / پرداخت و فاکتور درون‌برنامه‌ای بله چگونه کار می‌کند؟
Bale provides a native in-app payment system. You can send a structured invoice card or create a direct invoice link: When the user clicks pay, respond to the `pre_checkout_query` update, and verify completion using `Bale::inquireTransaction(['payment_charge_id' => $chargeId])`.
6. Can I manage multiple Bale bots in a single Laravel codebase? / آیا امکان مدیریت چندین بات بله به طور هم‌زمان وجود دارد؟
Yes, Multi-Bot management is supported out of the box! Register extra bot tokens in `config/bale.php`: Switch between bots seamlessly in your code:

🧪 Testing

Run the automated test suite using PHPUnit:


🤝 Contributing

Contributions are welcome and greatly appreciated!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Ensure all tests pass (composer test)
  5. Push to your branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

💖 Funding & Support

If this SDK helps you build awesome Bale bots, please consider supporting its ongoing maintenance and development:


📄 License & Disclaimer

Keywords


All versions of bale-bot-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
guzzlehttp/guzzle Version ^7.8
guzzlehttp/psr7 Version ^2.7
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
psr/container Version ^1.1 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package erfanvahabpour/bale-bot-sdk contains the following files

Loading the files please wait ...