尝试导入文件

问题描述 投票:-2回答:2

我是php的初学者,我正在尝试使用库,但我遇到了错误

致命错误:未捕获错误:在C:\ xampp \ htdocs \ index.php中找不到类'Einenlum \ LingueeApi \ Factory':4堆栈跟踪:#0 {main}在C:\ xampp \ htdocs \ index.php中引发第4行

the library is this

我正确地遵循了自述文件中的内容,我的代码是这样的:

<?php
use Einenlum\LingueeApi\Factory;

$linguee = Factory::create();

$response = $linguee->translate('desert', 'eng', 'ger');

echo $response->toJson();
?>

我不确定这个自述文件是否给了我正确的信息,我该如何运行这个项目? enter image description hereenter image descriptiodddddn here

php compose
2个回答
1
投票

由于该库/包是通过composer管理的,您需要使用composer的自动加载:

<?php
require __DIR__ . '/vendor/autoload.php';

use Einenlum\LingueeApi\Factory;
...

有关更多信息,请访问https://getcomposer.org/doc/01-basic-usage.md#autoloading


0
投票

您应该下载该库并输入C:\ xampp \ htdocs \以具有以下路径C:\ xampp \ htdocs \ Einen Zum \ Linguee Api \ Factory并设置文件读取,写入和执行权限

update 1

要在供应商文件夹中使用库,您应在路径中指定该库

 use vendor\Einenlum\LingueeApi\Factory;
© www.soinside.com 2019 - 2024. All rights reserved.