0

I tried to use PHP telegram bot in my CakePHP 3 website, but encountered many problems.
done
I ran "composer require longman/telegram-bot" and copied package to "plugins" folder.
and then "bin/cake plugin load longman/telegram-bot".
questions
1. Where I must put the package and why? vendor or plugins
2. How to call package methods in URL?
I added "index" method to "telegram-bot/src/Telegram.php" and tried this snippet code in my "Template/Users/index.ctp".
echo $this->Html->link('telegram', ['plugin' => 'longman/telegram-bot', 'controller' => 'telegram', 'action' => 'index']);
that results
Error: A route matching "array ( 'plugin' => 'longman/telegram-bot', 'controller' => 'telegram', 'action' => 'index', '_ext' => NULL, )" could not be found.
3. What I must add to "routes.php"?
4. How can I use "telegram-bot/src/Telegram.php" methods in my controllers and models.
5. Is there anything else that must be observed?
Thanks.

Community
  • 1
  • 1
mitra razmara
  • 745
  • 6
  • 10
  • Telegram bot isn't a [cakephp plugin](https://book.cakephp.org/3.0/en/plugins.html), so `Plugin::load('longman/telegram-bot')` will have no effect. The route's `controller` key is expecting the name of an `instanceof` [Controller](https://book.cakephp.org/3.0/en/controllers.html) -specifying an arbitrary class will have no effect. You would use this class the same way you would use any class (inside or outside of a controller): `$telegram = new Longman\TelegramBot\Telegram(...);` – jtrumbull May 23 '17 at 23:07
  • Thank you. very valuable guidance. I was confused yesterday. its done. – mitra razmara May 24 '17 at 07:57
  • @mitra razmara Please share your solutions. – Marwan Salim Sep 03 '20 at 04:33

0 Answers0