1. Go to this page and download the library: Download milly/laragram library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
milly / laragram example snippets
use Milly\Laragram\Laragram;
Laragram::sendMessage(
123456789, // chat_id
null, // message thread id
"Hello world", // message text
);
- Objects:
// routes/api.php
use Milly\Laragram\FSM\FSM;
use Milly\Laragram\Laragram;
Route::post('/bot', function () {
FSM::route('state_1', [SomeClass::class, 'someMethod']);
FSM::route('state_2', function (Message $message) {
Laragram::sendMessage(
$message->chat->id,
null,
"Inside anonymous function"
);
});
}
// routes/laragram.php
use App\Http\Controllers\LaragramController;
use Milly\Laragram\FSM\FSM;
use \Milly\Laragram\Types\Message;
use \Milly\Laragram\Laragram;
FSM::route('', function (Message $message) {
Laragram::sendMessage([
$message->chat->id,
null,
"Inside anonymous function"
);
}, [
(new \Milly\Laragram\Types\Update())->message
]);