hosseinhunta/php-telegram-api-bot

A PHP SDK for Telegram Bot API with full method support and robust error handling

0.1.2 2025-04-11 10:29 UTC

This package is auto-updated.

Last update: 2025-09-11 11:51:34 UTC


README

Telegram Bot API - PHP SDK Banner

Total Downloads Latest Stable Version Telegram Group GitHub Stars License Open Source Contributors

Telegram Bot API - PHP SDK (Beta)

This is a PHP SDK for the Telegram Bot API, designed to make building Telegram bots as easy and fun as possible! Whether you're a beginner or an experienced developer, this library is built with simplicity, security, and performance in mind. It comes packed with features, tons of examples, and—most importantly—a detailed documentation site that shows you just how simple it is to create Telegram bots with PHP.

We’ve worked hard to make this library a go-to tool for anyone looking to create Telegram bots without the hassle. It’s lightweight, secure, and optimized for real-world use cases, so you can focus on building your bot instead of wrestling with complicated code.

Supported Telegram Bot API Methods

This SDK currently supports all Telegram Bot API methods! Here’s a quick overview:

Method Supported
sendMessage
getMe
sendPhoto
sendAudio
sendDocument
sendVideo
sendAnimation
sendVoice
sendVideoNote
sendMediaGroup
getUpdates
setWebhook
deleteWebhook
getChat
getChatMember
answerCallbackQuery
...and more!

Yes, you read that right—every method in the Telegram Bot API is supported in this SDK! 🎉

Documentation

Want to dive deeper? Check out our detailed documentation, available in two languages:

The docs will guide you through everything—from installation to advanced usage—with plenty of examples to get you started.

TODO: Upcoming Features

We’re working hard to make this SDK even better! Here’s what’s on the horizon:

  • Build a command and event handler for better bot management.
  • Optimize the update handler for smoother performance.
  • Enhance code security and stability.
  • Complete and polish the documentation.
  • Update the SDK to support Telegram Bot API version 8.3.
  • Add support for complex data types.
  • Introduce middleware for advanced request handling.
  • Improve webhook management with advanced features.
  • Add advanced debugging tools (e.g., direct request/response dumping).
  • Implement extensive unit tests and integration tests to ensure stability.
  • Add plugin support for extending functionality.
  • Further optimize performance for large-scale bots.
  • Add support for inline query caching to reduce API calls.
  • Create a built-in rate limiter to handle Telegram API limits.
  • Add support for multi-bot management in a single instance.

Stay tuned for these updates as we continue to improve the SDK! 🚀

Repository Creator's Note

Hey there! Yep, it’s me again—another Telegram bot library. But you might be wondering: why create yet another one? What’s wrong with the existing libraries? And what makes this one different?

These days, I’m going through a pretty strange phase in my life—a time when I don’t have much free time to dive into my true passion: coding. I really wanted to kick off my first GitHub repository with something meaningful, something that reflects the very first library I ever wrote. After coming back from some personal challenges (and a 12-day break), I thought, “How can I enjoy coding again while solving one of my problems?” During that time, I listened to a lot of music, and I got this idea to create a Telegram channel that could act like a playlist for me. I wanted a bot that could upload music links or files I send it as files in the channel, so I could always listen to them and share them with others. Plus, I wanted it to create a playlist for my favorite music platform.

When I started working on this with my old library, I realized how much room for improvement there was. So, I put the bot idea on hold and focused on building a better library instead. My goal? To create a comprehensive and complete library—at least a beta version—that can stand toe-to-toe with other similar libraries out there! When I say “comprehensive,” I mean it should have super clear, simple, and easy-to-understand documentation. So, I set my priorities: simplicity, security, tons of features, optimization, lots of examples, and—most importantly—a documentation site that shows everyone just how easy it is to build a Telegram bot with PHP.

Now, you might ask: why PHP? Why not Python, JavaScript, or even Dart—a language I’ve been working with a lot lately and absolutely love? Well, the first language I ever learned (at a very basic level) was PHP. Then I moved on to Python, and since the first library I ever wrote was in Python, I wanted to go back to those early days when I first fell in love with programming. So, I decided to build this with PHP. Plus, it’s a great chance to level up my PHP skills! Honestly, PHP 8.4 has made the language so much more exciting, and I’m done throwing shade at it.

As I’m writing this, I’ve got 3 days left of my break. My plan is to release a beta version in these 3 days and finally build that music bot I’ve been dreaming about. I hope this library keeps moving forward! :)

Awesome Telegram Bots Built with Telegram Bot SDK!

Have you built a cool Telegram bot using this SDK? Let us know, and we’ll feature it here! Stay tuned for a growing list of awesome bots created by the community.

Additional Information

Any issues, feedback, suggestions, or questions? Please use the issue tracker here.

Contributing

Thank you for considering contributing to the project! Please review the CONTRIBUTING guidelines before submitting any pull requests.

Credits

This project was created by HossienHunTa.

Disclaimer

This SDK is currently in beta, and while we’ve done our best to ensure it works smoothly, there might be bugs or unexpected behavior. Use it at your own risk, and feel free to report any issues you encounter.

License

This project is licensed under the MIT License—feel free to use, modify, and distribute it as you like!