Download the PHP package hugphp/telegram without Composer
On this page you can find all versions of the php package hugphp/telegram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package telegram
HugPHP Telegram
A robust and type-safe Laravel package for interacting with the Telegram Bot API. This package provides a simple, performant, and flexible interface for sending messages, media, locations, contacts, and managing webhooks in your Laravel applications.
Features
- Type-Safe: Built with strict typing and validated by PHPStan for 100% type safety.
- Easy Integration: Seamlessly integrates with Laravel’s HTTP client and configuration system.
- Comprehensive API Support: Send messages, photos, videos, documents, locations, contacts, and manage webhooks.
- Retry Logic: Configurable retries and timeouts for reliable API communication.
- Tested: >83% test coverage with Pest, ensuring reliability and stability.
Feature Roadmap
| Feature | Method | Status |
|---|---|---|
| Send Message | sendMessage |
✅ Completed |
| Send Photo | sendPhoto |
✅ Completed |
| Send Video | sendVideo |
✅ Completed |
| Send Document | sendDocument |
✅ Completed |
| Send Location | sendLocation |
✅ Completed |
| Send Contact | sendContact |
✅ Completed |
| Set Webhook | setWebhook |
✅ Completed |
| Get Webhook Info | getWebhookInfo |
✅ Completed |
| Delete Webhook | deleteWebhook |
✅ Completed |
| Get Updates | getUpdates |
✅ Completed |
| Handle Callback Query | handleCallbackQuery |
☐ Pending |
| File Uploads | fileUploads |
☐ Pending |
| Send Notification | sendNotification |
☐ Pending |
Installation
Install the package via Composer:
Publish the configuration file:
This creates a config/telegram.php file for configuring your Telegram bot settings.
Configuration
Edit config/telegram.php to set your bot token and other settings:
Add the following to your .env file:
Usage
The package provides a Telegram facade for easy interaction with the Telegram Bot API. Below are examples for each supported method, based on tested functionality.
Sending a Message
Send a formatted HTML message with an inline keyboard:
Example Response:
Sending a Photo
Send a photo with a caption:
Example Response:
Sending a Video
Send a video with a caption:
Example Response:
Sending a Document
Send a document with a caption:
Example Response:
Sending a Location
Send a live location:
Example Response:
Sending a Contact
Send a contact with first and last name:
Example Response:
Setting a Webhook
Set a webhook for receiving updates:
Example Response:
Getting Webhook Info
Retrieve webhook information:
Example Response:
Deleting a Webhook
Delete the current webhook:
Example Response:
Getting Updates
Retrieve bot updates:
Example Response:
Testing
The package includes a comprehensive test suite with 100% coverage using Pest. You can test all functionalities in your Laravel project by accessing the /validate-all-functionalities route:
This route tests all Telegram API methods and returns a JSON response with the status and results for each:
Run unit tests to verify the package:
Check test coverage:
Contributing
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
License
This package is open-source software licensed under the MIT License.
Support
Hugphp Telegram was created by Micheal Ataklt.
For questions or support, open an issue on GitHub or contact the maintainer at [email protected].