首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OctoberCMS和BotMan

OctoberCMS和BotMan
EN

Stack Overflow用户
提问于 2018-11-23 15:10:54
回答 1查看 212关注 0票数 1

我想将一个聊天机器人(BotMan version 2.0)集成到一个现有的OctoberCMS项目中,下面是我迄今为止所做的工作:

1-我使用以下命令将BotMan添加到projct中:

代码语言:javascript
复制
composer require botman/botman

2-我在与plugin.php文件相同的目录中创建了一个routes.php文件。

代码语言:javascript
复制
<?php

use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;



//Route::match(['get', 'post'], '/botman', 'BotManController@handle');
//Route::get('/botman/tinker', 'October\Demo\BotManController@tinker');
// Create an instance
$botman = BotManFactory::create($config);

// Give the bot something to listen for.
$botman->hears('hello', function (BotMan $bot) {
    $bot->reply('Hello yourself.');
});

// Start listening
$botman->listen();

我的问题是:

1-我必须在其中添加BotManController.php文件 2-我试图将BotManController.php添加到与routes.php文件相同的目录中,但我得到了以下错误:

代码语言:javascript
复制
 Class 'App\Http\Controllers\Controller' not found

(这是因为这是一个OctoberCMS项目,而不是Laravel项目.我没有应用程序目录)

谁能给我提供一个解决方案,或以另一种方式将Botman集成到OctoberCMS中!

EN

回答 1

Stack Overflow用户

发布于 2018-11-24 16:56:41

首先,阅读https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/https://octobercms.com/docs/plugin/composer

其次,只要您了解PHP名称空间以及如何正确引用它,您就可以将BotManController文件放置在您想要的插件中的任何位置。我可能会建议将它放在插件文件夹下的/ Illuminate\Routing\Controller /目录中,然后将Illuminate\Routing\Controller引用更改为引用基类Illuminate\Routing\Controller。您也可以将它放在/ controllers /目录中,但是在OctoberCMS中通常是为后端控制器保留的,所以我不建议将两者混合使用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53449075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档