Telegram Bot Package for Laravel 6.x, 7.x, and 8.x
, (*1)
This package helps easily integrate PHP Telegram Bot library in Laravel application., (*2)
Table of Contents
Installation
Install this package through Composer., (*3)
Edit your project's composer.json
file to require php-telegram-bot/laravel
, (*4)
Create composer.json file:, (*5)
{
"name": "yourproject/yourproject",
"type": "project",
"require": {
"php-telegram-bot/laravel": "^1.0"
}
}
And run composer update, (*6)
Or run a command in your command line:, (*7)
composer require php-telegram-bot/laravel
Copy the package config and migrations to your project with the publish command:, (*8)
php artisan vendor:publish --provider="PhpTelegramBot\Laravel\ServiceProvider"
After run migration command, (*9)
php artisan migrate
In the config you have to specify Telegram API KEY, (*10)
Usage
You can inject PhpTelegramBot\Laravel\PhpTelegramBotContract
in anywhere and use bot instance, (*11)
For example:, (*12)
<?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, (*13)
TODO
write more tests, (*14)
Troubleshooting
If you like living on the edge, please report any bugs you find on the
php-telegram-bot/laravel issues page., (*15)
Contributing
Pull requests are welcome.
See CONTRIBUTING.md for information., (*16)
License
Please see the LICENSE included in this repository for a full copy of the MIT license,
which this project is licensed under., (*17)
Credits
Full credit list in CREDITS, (*18)