Laravel package for PHP Telegram Bot Library
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src IUmprove build scenario and fix code style Apr 21, 2018
tests
.editorconfig Initial commit Apr 18, 2018
.gitignore Ignore composer lock file Apr 21, 2018
.scrutinizer.yml Update build config Apr 21, 2018
.travis.yml Add tests Apr 21, 2018
CONTRIBUTING.md Initial commit Apr 18, 2018
CREDITS Initial commit Apr 18, 2018
LICENSE.md Initial commit Apr 18, 2018
README.md
composer.json
phpcs.xml
phpunit.xml.dist Initial commit Apr 18, 2018

README.md

Telegram Bot Package for Laravel 5.x

Build Status Code Coverage Code Quality Latest Stable Version Total Downloads Downloads Month Minimum PHP Version License

This package helps easily integrate PHP Telegram Bot library in Laravel application.

Table of Contents

Installation

Install this package through Composer.

Edit your project's composer.json file to require php-telegram-bot/laravel

Create composer.json file:

{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "php-telegram-bot/laravel": "~0.1"
    }
}

And run composer update

Or run a command in your command line:

composer require php-telegram-bot/laravel

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:

PhpTelegramBot\Laravel\PhpTelegramBotServiceProvider::class,

Copy the package config and migrations to your project with the publish command:

php artisan vendor:publish --provider="PhpTelegramBot\Laravel\PhpTelegramBotServiceProvider"

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 $telegram_bot)
    {
        // Call handle method
        $telegram_bot->handle();
        
        // Or set webhook 
        $telegram_bot->setWebhook($hook_url);
        
        // Or handle telegram getUpdates request
        $telegram_bot->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 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.

Credits

Full credit list in CREDITS