|
1 | 1 | # Telegram Bot Package for Laravel 5.x
|
2 | 2 |
|
3 |
| -TBD |
| 3 | +## Table of Contents |
| 4 | +- [Installation](#installation) |
| 5 | +- [Usage](#usage) |
| 6 | +- [TODO](#todo) |
| 7 | +- [Troubleshooting](#troubleshooting) |
| 8 | +- [Contributing](#contributing) |
| 9 | +- [License](#license) |
| 10 | +- [Credits](#credits) |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +Install this package through [Composer](https://getcomposer.org/). |
| 15 | + |
| 16 | +Edit your project's `composer.json` file to require `longman/laravel-multilang` |
| 17 | + |
| 18 | +Create *composer.json* file: |
| 19 | +```json |
| 20 | +{ |
| 21 | + "name": "yourproject/yourproject", |
| 22 | + "type": "project", |
| 23 | + "require": { |
| 24 | + "php-telegram-bot/laravel": "~0.1" |
| 25 | + } |
| 26 | +} |
| 27 | +``` |
| 28 | +And run composer update |
| 29 | + |
| 30 | +**Or** run a command in your command line: |
| 31 | + |
| 32 | + composer require php-telegram-bot/laravel |
| 33 | + |
| 34 | +In Laravel 5.5 the service provider will automatically get registered. |
| 35 | +In older versions of the framework just add the service provider in `config/app.php` file: |
| 36 | + |
| 37 | +```php |
| 38 | +PhpTelegramBot\Laravel\PhpTelegramBotServiceProvider::class, |
| 39 | +``` |
| 40 | + |
| 41 | +Copy the package config and migrations to your project with the publish command: |
| 42 | + |
| 43 | + php artisan vendor:publish --provider="PhpTelegramBot\Laravel\PhpTelegramBotServiceProvider" |
| 44 | + |
| 45 | + |
| 46 | +After run migration command |
| 47 | + |
| 48 | + php artisan migrate |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +You can inject `PhpTelegramBot\Laravel\PhpTelegramBotContract` in anywhere and use bot instance |
| 53 | + |
| 54 | +For example: |
| 55 | + |
| 56 | +```php |
| 57 | +<?php |
| 58 | +namespace App\Http\Controllers; |
| 59 | + |
| 60 | +use PhpTelegramBot\Laravel\PhpTelegramBotContract; |
| 61 | + |
| 62 | +class CustomController extends Controller |
| 63 | +{ |
| 64 | + public function handle(PhpTelegramBotContract $telegram_bot) |
| 65 | + { |
| 66 | + // Call handle method |
| 67 | + $telegram_bot->handle(); |
| 68 | + |
| 69 | + // Or set webhook |
| 70 | + $telegram_bot->setWebhook($hook_url); |
| 71 | + |
| 72 | + // Or handle telegram getUpdates request |
| 73 | + $telegram_bot->handleGetUpdates(); |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +``` |
| 78 | + |
| 79 | +More details about usage you can see on the PHP Telegram Bot docs: https://github.com/php-telegram-bot/core#instructions |
4 | 80 |
|
5 | 81 | ## TODO
|
6 | 82 |
|
|
0 commit comments