php - 致命错误:未找到接口“Coinbase\Wallet\Authentication\Authentication”
问题描述
我正在尝试创建 PHP API,我已经从 GitHub 下载了 PHP 库并创建了一个 index.php 文件以开始工作,下面是索引代码
<?php
require_once('src/Client.php');
require_once('src/Configuration.php');
require_once('src/Authentication/ApiKeyAuthentication.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey="";
$apiSecret="";
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
?>
这会产生以下错误
致命错误:在第 8 行的 /home/exhakduz/api/coinbase-php-master/src/Authentication/ApiKeyAuthentication.php 中找不到接口“Coinbase\Wallet\Authentication\Authentication”我找不到任何解决方案
解决方案
composer
改为使用,并composer
在您的index.php
. 文档建议也安装该库composer
。
使用 Composer 安装库。如果您不熟悉 Composer 或依赖管理器,请阅读 Composer 文档。
作曲家设置/安装
注意:下面的所有命令都需要从 index.php 所在的同一目录中运行。
首先,您需要下载并安装 composer。当前可用的版本是
1.8.6
. 将其下载到与您的脚本phar
相同的位置。index.php
同时创建一个composer.json
文件{}
作为内容,composer
将你的依赖项保存到这个文件中。确保
composer.phar
具有执行权限(如果在 linux 上运行chmod +x ./composer.phar
)运行
./composer.phar require coinbase/coinbase
。这应该将依赖项安装在一个vendor
目录中。
最后,您可以autoloader
composer
在安装依赖项时要求生成,您看到的缺失Interface
错误将得到解决。
该composer.json
文件应包含以下内容(最低限度):
{
"require": {
"coinbase/coinbase": "^2.8"
}
}
使用自动加载器的示例
<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey="";
$apiSecret="";
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
推荐阅读
- ansible - 使用 ansible Vault 创建具有相同密码的多个用户
- python - 如何在代码中更改不和谐机器人头像 [python]
- database - 如何在flutter中将值插入到sqflite数据表的特定行中
- python - Pandas 解析文本数据并分配列
- docker - 如何在自定义网络上允许对 Docker 容器的完全入站和出站 Internet 访问?
- python - 使用一个不带变量的 for 循环查找字符串中的重复字符
- iis - IIS 服务器配置 SignalR - WebSocket
- r - R:单变量的幂曲线
- python - 骰子损失变化(平均,每个块的最大值)
- java - 如何在android studio中显示所有文件和文件夹,如文件管理器