【发布时间】:2018-11-19 19:04:46
【问题描述】:
我创建了一个使用 psr-4 自动加载的类。 在这堂课中,我想使用我用 composer 下载的一些库中的类,问题是我似乎无法弄清楚。 类:
<?php
namespace CusTelegram\CusCommand;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
class NewEpisodeCommand extends Command
{
public function handle($arguments)
{
...
$dotenv = new Dotenv\Dotenv(__DIR__ . "/../..");
$this->replyWithMessage(['text' => __DIR__ . "/../.."]);
$dotenv->overload();
$client = new ApiVideo\Client\Client($_ENV["API_EMAIL"], $_ENV["API_KEY"]);
...
}
方法句柄是从电报 webhook 调用的,所以我不知道如何对其进行调试,但我 100% 确定当 Dotenv 尝试实例化时它会崩溃。 树状图:
/CusTelegram
/CusCommand
/NewEpisodeCommand.php (this class)
/bot
/bot.php
/vendor
...
在 bot php 中,我已经需要自动加载。这个类没有问题,只是我不能在 NewEpisodeCommand 类中使用 DotEnv 和 ApiVideo。 bot.php:
ini_set('memory_limit', '-1');
require_once '../vendor/autoload.php';
use Telegram\Bot\Api;
$telegram = new Api(<token>);
$commands = [CusTelegram\CusCommand\StartCommand::class, CusTelegram\CusCommand\NewEpisodeCommand::class, Telegram\Bot\Commands\HelpCommand::class ];
$telegram->addCommands($commands);
$update = $telegram->commandsHandler(true);
--编辑-- 我能够打印错误,这就是我得到的:
Fatal error: Uncaught Error: Class 'CusTelegram\CusCommand\Dotenv\Dotenv' not found in /membri/streamapi/CusTelegram/CusCommand/NewEpisodeCommand.php
【问题讨论】:
-
我看不到问题,因为它是从电报 api 调用的,因为它在 webhook 中并且在我的主机上我无法访问错误日志文件夹
-
如果您不能告诉我们错误,我们将无法为您提供帮助。考虑为它编写测试,并找到一种在本地测试它的方法。
-
有没有办法在我所在的文件夹中记录错误?各种方法都试过了,还是不行。
-
我能够打印错误
标签: php composer-php php-telegram-bot