PHP code example of violetsun / max

1. Go to this page and download the library: Download violetsun/max 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/ */

    

violetsun / max example snippets


MAX::sendMessage(
    1234567890, 
    [
        'text' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
        // there will be more to come...
    ]
);

Max::builder()
    ->chatId(1234567890)
    ->text("Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
    ->attachments(function (AttachmentsBuilder $builder) {
        $builder->image(
            token: "TOKEN_IMAGE"
        );
        $builder->image(store: public_path('image.png'));
        $builder->video(
            token: "TOKEN_VIDEO"
        );
        $builder->inlineKeyboard(
            $builder->row(
                $builder->button->link(
                    text: "Lorem Ipsum 1",
                    url: "https://max.ru",
                ),
                $builder->button->callback(
                    text: "Lorem Ipsum 2",
                    payload: "lorem-ipsum-2",
                )
            ),
            $builder->button->callback(
                text: "Lorem Ipsum 3",
                payload: "lorem-ipsum-3",
            )
        );
    })
    ->send();

Max::builder()
    ->chatId(1234567890)
    ->text("Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
    ->attachments(function (AttachmentsBuilder $builder) {
        $builder->image(
            token: "TOKEN_IMAGE"
        );
        $builder->inlineKeyboard(
            $builder->button->callback(
                text: "Lorem Ipsum 1",
                payload: "lorem-ipsum-1",
            )
        );
    })
    ->queue();

$queueMessage = MaxMessageQueue::query()->first();
$queueMessage?->sendQueuedMessage();

use Illuminate\Support\Facades\Schedule;

Schedule::command('max:message-queue:handle')
    ->everyThirtySeconds()
    ->withoutOverlapping();

php artisan schedule:work
bash
php artisan vendor:publish --provider="VioletSun\MAX\MAXServiceProvider"
bash
php artisan vendor:publish --tag=max-config
php artisan vendor:publish --tag=max-migrations
php artisan vendor:publish --tag=max-models
php artisan vendor:publish --tag=max-assets
php artisan vendor:publish --tag=max-services
bash
php artisan migrate