Download the PHP package haikiri/messenger-routing without Composer

On this page you can find all versions of the php package haikiri/messenger-routing. 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 messenger-routing

Messenger Router

Attribute Commands handler for your messengers, works like Symfony/Routing, or like this: luzrain/telegram-bot-bundle for Symfony.

But I believe this library can be used not only with Telegram, but also with your other messengers! This code present as an idea, based on attributes introduced in PHP 8 and above. This library is native, and has no dependencies or bindings with some external libraries. Hope there will be cool ideas, fixes, and implementations based on this project idea!
If you need to make any changes, write to the contact details in composer.json.


Installation


Requirements:


Theory, how it works:

See examples in tests/Mocked.


Errors

Please note, if no command has been found, you can catch this discrepancy and implement your behavior. This will not cause an exception if the command is not found. The code will continue to work.

Обрати внимание, если ни одна команда не была найдена, ты можешь отловить это расхождение и реализовать своё поведение. Это не вызовет исключение, если команда не найдена. Код продолжит работу.

Access rights

Your controller supports access rights restrictions. These rights are implemented by you in your model.
This means that now you have separation between administrator, chat owner, and environment administrators.

Hierarchy of rights:

This means that an admin cannot execute commands specific for the chat creator or environment administrator.
At the same time, the environment administrator can do everything that others cannot.
It expected that the list of admin’s IDs will be listed in your project's .ENV file as a string, separated by commas. However, you can implement your own method for getting the list of admins in your contract.


Usage

I recommend looking at the implementation example in the tests/Mocked.

Structure:

First, let's make your entrypoint. A Webhook will be configured on this page.

/src/Controller/ApiController.php

If you are use Symfony:

Symfony Controller Usage

If you are use Symfony, try for use Symfony Tags... Something like this:

Now let's create a Telegram Messenger class that will process your Telegram requests. Connect your Telegram SDK in the constructor. Please, use your real library! This is just an example!

/src/Messenger/TelegramMessenger.php

If you are use Symfony:

If you are not use Symfony:

Write the extends TelegramContract and create an abstract class, where we'll write the data for your command handler. Connecting your interface from the new library \Haikiri\MessengerRouting\MessengerContractInterface:

/src/Messenger/TelegramContract.php

After creating all the main classes, u will make a trial command handler in private messages with the bot. See example for PrivateRoom.php:

/src/Messenger/Telegram/PrivateRoom.php

Note that your bot accepts commands without special characters such as "/" by default. The short "/command" is equivalent to "command", and "!command" as a "command". etc...

Small example. When you pass: ["ban", "бан"] Can be triggered on: ban, /ban, !ban, ban!, Ban!, Ban?, Ban!!!!!!, !BaN! etc...

Allow this in the settings inside BotFather.


All versions of messenger-routing with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-mbstring Version *
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 haikiri/messenger-routing contains the following files

Loading the files please wait ...