Composer.json 在 AWS Elastic Beanstalk 上安装
Composer.json Installation On AWS Elastic Beanstalk
我在 AWS Elastic Beanstalk 文档中读到,您可以简单地将 composer.json 文件包含在包的根目录中,它将安装一个应用程序及其依赖项:
{
"require": {
"coinbase/coinbase": "~2.0"
}
}
然后我创建了一个 PHP 文件,其中包含以下内容以测试它是否有效:
error_reporting(E_ALL);
ini_set('display_errors', 1);
$apiKey = 'workingkey';
$apiSecret = 'workingkey';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$buyPrice = $client->getBuyPrice('BTC-USD');
echo $buyPrice;
不幸的是,它给出了以下错误:
Fatal error: Uncaught Error: Class 'Coinbase\Wallet\Configuration' not found in /var/app/current/test.php:20 Stack trace: #0 {main} thrown in /var/app/current/test.php on line 20
我已尽我所能使它正常工作。我在这里错过了什么?
您错过了包含 composer 的自动加载器。
将此添加到文件的开头,它应该可以工作:
require __DIR__.'/vendor/autoload.php';
我在 AWS Elastic Beanstalk 文档中读到,您可以简单地将 composer.json 文件包含在包的根目录中,它将安装一个应用程序及其依赖项:
{
"require": {
"coinbase/coinbase": "~2.0"
}
}
然后我创建了一个 PHP 文件,其中包含以下内容以测试它是否有效:
error_reporting(E_ALL);
ini_set('display_errors', 1);
$apiKey = 'workingkey';
$apiSecret = 'workingkey';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$buyPrice = $client->getBuyPrice('BTC-USD');
echo $buyPrice;
不幸的是,它给出了以下错误:
Fatal error: Uncaught Error: Class 'Coinbase\Wallet\Configuration' not found in /var/app/current/test.php:20 Stack trace: #0 {main} thrown in /var/app/current/test.php on line 20
我已尽我所能使它正常工作。我在这里错过了什么?
您错过了包含 composer 的自动加载器。
将此添加到文件的开头,它应该可以工作:
require __DIR__.'/vendor/autoload.php';