codev-vn / php-telegram-bot-laravel
Package to integrate PHP Telegram Bot library in Laravel 8.x
Requires
- php: ^7.2
- illuminate/database: ^8.50
- illuminate/support: ^8.50
- longman/telegram-bot: ^0.74.0
Requires (Dev)
- graham-campbell/testbench: ^5.6
- longman/php-code-style: ^7.0
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-11-15 21:59:27 UTC
README
This package helps easily integrate PHP Telegram Bot library in Laravel application.
Table of Contents
Installation
Install this package a command in your command line:
composer require codev-vn/php-telegram-bot-laravel
Copy the package config and migrations to your project with the publish command:
php artisan vendor:publish --provider="PhpTelegramBot\Laravel\ServiceProvider"
After run migration command
php artisan migrate
In the config you have to specify Telegram API KEY
Usage
You can inject PhpTelegramBot\Laravel\PhpTelegramBotContract
in anywhere and use bot instance
For example:
<?php namespace App\Http\Controllers; use PhpTelegramBot\Laravel\PhpTelegramBotContract; class CustomController extends Controller { public function handle(PhpTelegramBotContract $telegramBot) { // Call handle method $telegramBot->handle(); // Or set webhook $hookUrl = 'https://hook.url'; $telegramBot->setWebhook($hookUrl); // Or handle telegram getUpdates request $telegramBot->handleGetUpdates(); } }
More details about usage you can see on the PHP Telegram Bot docs: https://github.com/php-telegram-bot/core#instructions
TODO
write more tests
Troubleshooting
If you like living on the edge, please report any bugs you find on the codev-vn/php-telegram-bot-laravel issues page.
Contributing
Pull requests are welcome. See CONTRIBUTING.md for information.
License
Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.