- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
所以,我正在尝试使用 coinbase API。我正在尝试一个简单的测试,看看我是否可以让它工作,但我遇到了各种 Composer 错误。
目前,我正在意外地“使用”此代码:
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey = 'public';
$apiSecret = 'private';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$spotPrice = $client->getSpotPrice();
echo $spotPrice;
那么,我的 use 语句是不是放错地方了?我在索引函数之外和类之外尝试了它们。两者都产生与此完全不同的结果集。
在 Keks 类之外,我得到
Fatal error: Class 'Coinbase\Wallet\Configuration' not found in /home/content/61/11420661/html/beta/application/controllers/keks.php on line 15
在类内部但在 index() 函数之外我得到
Fatal error: Trait 'Coinbase\Wallet\Client' not found in >/home/content/61/11420661/html/beta/application/controllers/keks.php on line 4
是不是我的 composer.json 有问题?
完整的 Controller 在这里:http://pastebin.com/4BjPP6YR
最佳答案
您不能在使用它的地方使用“use”。
“use”关键字要么在类定义前面以将其他类/接口(interface)/特征导入它自己的命名空间,要么在类内部(但不在方法内部)以向类添加特征。
<?php
namespace Foo;
use Different\Class; // use can go here
class Bar {
use TraitCode; // use can go here
public function baz() {
$this->traitFunction('etc');
// use CANNOT go here
}
}
关于php - 尝试使用 Composer 时意外的 'use' (T_USE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33342994/
所以基本上我想创建多个 PrestaShop 模块。有时会在同一家商店中激活几个模块。问题是我想在两个模块中使用不同定义的类“MyTools”。 那会导致类重定义错误。我的解决方案是使用命名空间: '
我想使用 PHPMailer 类进行测试。看完official documentation我看到有两种方法可以将它们包含在我的项目中: 1) 使用 Composer 2) 复制内容并包含路径 我不知道
所以,我正在尝试使用 coinbase API。我正在尝试一个简单的测试,看看我是否可以让它工作,但我遇到了各种 Composer 错误。 目前,我正在意外地“使用”此代码:
我正在使用最新版本的 Laravel。新鲜的项目。刚刚创建了 make:auth 函数。 我的目标是向注册字段添加其他字段。原始模型只需要姓名、电子邮件和密码。我正在使用 SQLite 和 PHP 7
我在使用 CodeIgniter 中的 PHPSpreadsheet 库创建测试文件时遇到问题。当我运行下面的代码时,我收到错误消息: An uncaught Exception was encoun
我在使用 CodeIgniter 中的 PHPSpreadsheet 库创建测试文件时遇到问题。当我运行下面的代码时,我收到错误消息: An uncaught Exception was encoun
这个问题在这里已经有了答案: PHP parse/syntax errors; and how to solve them (20 个回答) 5年前关闭。 ob_start(); require_o
我是一名优秀的程序员,十分优秀!