Php 电报机器人SDK添加命令
我使用的是laravel 5.4和 我想向我的机器人添加命令 我试图添加的Php 电报机器人SDK添加命令,php,laravel,laravel-5.4,telegram,Php,Laravel,Laravel 5.4,Telegram,我使用的是laravel 5.4和 我想向我的机器人添加命令 我试图添加的StartCommand,但出现错误 Command class "Vendor\App\Commands\StartCommand" not found! 但文件上说: 只要可以根据composer.json设置自动加载命令,就可以将自定义命令存储在任何目录中 我将StartCommand类存储在app\StartCommand.php中 这是我的composer.json: ... , "autoload": {
StartCommand
,但出现错误
Command class "Vendor\App\Commands\StartCommand" not found!
但文件上说:
只要可以根据composer.json
设置自动加载命令,就可以将自定义命令存储在任何目录中
我将StartCommand类
存储在app\StartCommand.php
中
这是我的composer.json
:
...
,
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
...
这是telegrom机器人sdk配置,位于`config\telegram.php:
...
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
Vendor\App\Commands\StartCommand::class,
],
];
我必须使用文件的当前名称空间 如果我将命令文件存储在
app\
中,我应该使用
namespace App;
在我的代码中,而不是
namespace Vendor\App\Commands;
在config\telegrame.php
中:
...
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
App\StartCommand::class,
],
];