PHP code example of labile / vk-keyboard

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

    

labile / vk-keyboard example snippets




staroth\VkKeyboard\Facade;
use Astaroth\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface;
use Astaroth\VkKeyboard\Object\Keyboard\Button\Text;

$keyboard = Facade::createKeyboardBasic(function (FactoryInterface $factory) {
    return [
        [
            $factory->location([]),
        ],
        [
            $factory->text('Текстовая кнопка', ['button' => 1], Text::COLOR_RED),
            $factory->callback('callback кнопка', ['button' => 2], Text::COLOR_BLUE),
            $factory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
        ],
        [
            $factory->pay('action=transfer-to-group&group_id=1&aid=10')
        ],
        [
            $factory->app('Кнопка приложения', 6979558, '-181108510', 'sendKeyboard')
        ]
    ];
});




staroth\VkKeyboard\Facade;
use Astaroth\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface;
use Astaroth\VkKeyboard\Object\Keyboard\Button\Text;

$keyboard = Facade::createKeyboardInline(function (FactoryInterface $factory) {
    return [
        [
            $factory->location([]),
        ],
        [
            $factory->text('Текстовая кнопка', ['button' => 1], Text::COLOR_RED),
            $factory->callback('callback кнопка', ['button' => 2], Text::COLOR_BLUE),
            $factory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
        ],
        [
            $factory->pay('action=transfer-to-group&group_id=1&aid=10')
        ],
        [
            $factory->app('Кнопка приложения', 6979558, '-181108510', 'sendKeyboard')
        ]
    ];
});




staroth\VkKeyboard\Facade;
use Astaroth\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface as ButtonFactoryInterface;
use Astaroth\VkKeyboard\Contracts\Template\Carousel\Element\FactoryInterface as CarouselElementInterface;

$templateWithOpenPhoto = Facade::createCarousel(function (CarouselElementInterface $elementFactory, ButtonFactoryInterface $buttonFactory) {
    return [
        $elementFactory->openPhoto([
            $buttonFactory->location(['button' => 'location']),
            $buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
            $buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
        ], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
        $elementFactory->openPhoto([
            $buttonFactory->location(['button' => 'location']),
            $buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
            $buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
        ], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
        $elementFactory->openPhoto([
            $buttonFactory->location(['button' => 'location']),
            $buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
            $buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
        ], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
    ];
});