Php 致命错误:未捕获错误:类';Mollie\Api\MollieApiClient';找不到

Php 致命错误:未捕获错误:类';Mollie\Api\MollieApiClient';找不到,php,api,Php,Api,因此,这是我第一次在事务中使用API,但我很难导入该类 我使用Mollie API并将其与composer一起安装 我使用mollie 2.0 这是我的文件夹结构的外观以及我存储自动加载器的位置: htdocs->vendor->autoload.php 以下是我的主项目文件夹的外观: htdocs->elf->mollieApi.php //(mollieApi is where I try to call the API and do stuff) // auto

因此,这是我第一次在事务中使用API,但我很难导入该类

我使用Mollie API并将其与composer一起安装

我使用mollie 2.0

这是我的文件夹结构的外观以及我存储自动加载器的位置:

htdocs->vendor->autoload.php
以下是我的主项目文件夹的外观:

htdocs->elf->mollieApi.php //(mollieApi is where I try to call the API and do stuff)
// autoload
require __DIR__ . "/../vendor/autoload.php";

// API key
require "api_keys/apiKey.php";

//Database connection
require("../database/connection.php");

// Use Mollie
use Mollie\Api\MollieApiClient;

$mollie = new MollieApiClient(); //this line doesn't work and throws the fatal error
$mollie->setApiKey(api_key);

//more stuff regarding mollie, but pretty useless to share
elf
目录中,我有一个
mollie-api-php
文件夹,当您使用composer时可以下载该文件夹

这是mollieApi.php的样子:

htdocs->elf->mollieApi.php //(mollieApi is where I try to call the API and do stuff)
// autoload
require __DIR__ . "/../vendor/autoload.php";

// API key
require "api_keys/apiKey.php";

//Database connection
require("../database/connection.php");

// Use Mollie
use Mollie\Api\MollieApiClient;

$mollie = new MollieApiClient(); //this line doesn't work and throws the fatal error
$mollie->setApiKey(api_key);

//more stuff regarding mollie, but pretty useless to share
我的
composer.json
看起来像这样,它位于我的
htdocs
中:

{
    "require": {
        "mollie/mollie-api-php": "^2.0"
    }
}
我尝试过的:

  • mollie api php
    映射移动到供应商映射中
  • 已将
    autoload.php
    移动到
    elf
    目录中
  • 尝试取出抛出错误的类等,并将其放在我的
    elf
    目录中(该目录起作用,但随后它开始抱怨必须导入其他内容,我可以断定解决方案将变成地狱,因为我还必须导入其他目录等)
  • 我查了几个关于这个的StackOverflow问题,但不幸的是,它们都太具体了,这些问题似乎不适用于我的问题
我想要实现的目标:


我希望能够导入(自动加载)Mollie类,了解我做错了什么(
使用Mollie\Api\MollieApiClient;
),并能够实际使用它。

Composer将Mollie Api php目录放入
供应商/Mollie/Mollie Api php/
目录。您是如何使用Composer安装它的?请显示您的composer.json文件。我进行了编辑以供您查看。