PHP code example of sm9sh / botman-bundle
1. Go to this page and download the library: Download sm9sh/botman-bundle 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/ */
sm9sh / botman-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sgomez\Bundle\BotmanBundle\BotmanBundle(),
// ...
);
}
// file: src/Controller/WebhookController.php
declare(strict_types=1);
namespace App\Controller;
use BotMan\BotMan\BotMan;
use Symfony\Component\HttpFoundation\Response;
class WebhookController
{
public function __invoke(BotMan $bot): Response
{
// Add your logic here
// Echo bot example
$bot->fallback(function (BotMan $bot): void {
$bot->reply($bot->getMessage()->getText());
});
// Stop touching
$bot->listen();
return new Response('', Response::HTTP_OK);
}
}