Seamless integration of xBot the powerful PHP library for creating Telegram bots with the Laravel framework.
- Artisan Commands: Use xBot through familiar Laravel commands
- Laravel Cache Integration: Automatic PSR-16 adapter
- Laravel Configuration: Native Laravel configuration system
- API Ready: Automatic Laravel Sanctum configuration
- Webhook Management: Easy webhook configuration for Telegram bots
composer require al3x5/xbot-laravelphp artisan xbotThis command will:
- Configure the Laravel API (Sanctum)
- Publish the xBot configuration
- Guide you through setting up your bot
- Adapt the configuration for your environment Laravel
php artisan xbot:hook:set https://yourdomain.com/xbot/webhookphp artisan xbot telegram:command HelloWorldphp artisan xbot registerAll commands available in xBot, except php vendor/bin/xbot install. This command is replaced by php artisan xbot.
After installation, add to your .env:
BOT_TOKEN=1234567890:ABCDEFGHIJKLMNOQRSTZ
ADMIN_TELEGRAM_ID=123456789,985632147
Add to your routes/api.php:
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('/bot', function (Request $request) {
$bot = new Al3x5\xBot\Bot(config('xbot'));
$bot->run();
});Inject xBot services into your controllers:
use H3x5\xBot\Bot;
public function sayHelloWorld(Request $request, Bot $bot)
{
return $bot->sendMessage([
'chat_id' => 'CHAT_ID',
'text' => 'Hello World'
]);
}- PHP 8.2+
- Laravel 12.x
- xBot Library (automatically installed)
MIT License - see the LICENSE file for details.
Need help? Open an issue on GitHub or consult the xBot documentation.