Download the PHP package slim4ikoff/vkslim without Composer

On this page you can find all versions of the php package slim4ikoff/vkslim. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vkslim

Callback

<?php
require_once 'vendor\autoload.php';

use VkSlim\Methods\Bot;
use VkSlim\VkCallback;

$callback = new VkCallback('токен бота', 'строка подтверждения');

$callback->event('message_new', function (Bot $bot, object $object, int $group_id) {
    if($bot->rules()->commandRule(['stop', 'start'], ['/', '!'])) {
        $bot->reply('Отреагировал на команду /start или !start ну или /stop !stop');
    } elseif($bot->rules()->attachmentsRule(['photo', 'video'])) {
        $bot->reply('Вы прислали мне фото и|или видео!');
    }

    $bot->answer('Привет мир, ты так прекрасен!');
});

$callback->listener(true);

Состояния (State)

class MainState {
    use State;

    private array $states = ['name', 'age', 'sex'];

    protected function getStates(): array {
        return $this->states;
    }
}

$callback = new VkCallback($token, $confirmation, $secret, $group_id);

$callback->event('message_new', function (Bot $bot, $object, $group_id) {
    $state = new MainState($object);

    if($bot->rules()->commandRule('start', ['/', '!']) && $state->isCurrent('*')) {
        $bot->answer('Введите ваше имя');
        $state->first();
    } elseif($state->isCurrent('name')) {
        $bot->answer('Введите ваш возраст');
        $state->next($object->message->text);
    } elseif($state->isCurrent('age')) {
        $bot->answer('Введите ваш пол');
        $state->next($object->message->text);
    } else {
        $state->finish($object->message->text);
        $bot->answer('Спасибо '.json_encode($state->getData()));
    }
});

$callback->listener(true);

Правила (Rules)

$bot->rules()->commandRule(['stop', 'start'], ['/', '!']) или $bot->rules()->commandRule('start', ['/', '!'])
$bot->rules()->attachmentsRule(['photo', 'video']) или $bot->rules()->attachmentsRule('photo')
$bot->rules()->peerRule()
$bot->rules()->stickerRule() или $bot->rules()->stickerRule(12719234) 
$bot->rules()->messageLengthRule(15)

Клавиатура (Keyboard)

use VkSlim\Keyboard\Keyboard;
use VkSlim\Keyboard\Buttons\Color;
use VkSlim\Keyboard\Buttons\CallbackButton;
use VkSlim\Keyboard\Buttons\LinkButton;
use VkSlim\Keyboard\Buttons\LocationButton;
use VkSlim\Keyboard\Buttons\PayButton;
use VkSlim\Keyboard\Buttons\TextButton;

$keyboard = new Keyboard();
$k = $keyboard
    ->create(inline: true)
    ->add(new TextButton('Text button', Color::POSITIVE, ['button' => 'one']))
    ->add(new LinkButton('Нажми меня', 'https://github.com/YoppiDev/VkSlim', payload: ['button' => 'two']))
    ->row()
    ->add(new CallbackButton('Callback кнопка', Color::PRIMARY, ['callback' => 'done']))
    ->add(new LocationButton(['callback' => 'done']))
    ->add(new PayButton('hash', ['button' => 'pay']))
    ->json();

DATABASE

Инициализация

$database = new \VkSlim\Wrappers\Database();
$database->connect('mysql', '127.0.0.1', 'root', '', 'test');

Префикс таблиц

$database->setPrefix('myprefix');

В результате sql запрос будет выглядеть так SELECT FROM myprefix_test, DELETE FROM myprefix_test и т.д.

Выполнение sql запросов

$result = $database->query('SELECT * FROM test WHERE id = :id', [
    'id' => 1
])->fetch();

или

$result = $database->query('SELECT * FROM table WHERE id = 5')->fetch();

Функция query возвращает объект PDOStatement

INSERT

$result = $database->multi_insert('test', [
    'name' => 'Лешка', 
    'warnings' => 0,
]);

Эквивалентно запросу

INSERT INTO test (name, warnings) VALUES (?,?)

Вы так же можете при необходимости добавлять сразу множество записей в таблицу

$result = $database->multiInsert('test', [
    ['name' => 'Лешка', 'warnings' => 0],
    ['name' => 'Васька', 'warnings' => 1],
    ['name' => 'Петька', 'warnings' => 1],
]);

UPDATE

$database->update('test', ['name' => "Петро", 'warnings' => 0], ['id' => 8,'name' => "Валентин"]);

Эквивалентно запросу

UPDATE test SET name=:name, warnings=:warnings WHERE id=:id2 AND name=:name2

All versions of vkslim with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-pdo Version *
ext-curl Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slim4ikoff/vkslim contains the following files

Loading the files please wait ....