作曲家.在AWS Elastic Beanstalk上安装


Composer.json Installation On AWS Elastic Beanstalk

我在AWS Elastic Beanstalk文档中看到,您可以简单地包含编写器。它会安装一个应用程序和它的依赖项:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html php-configuration-composer

{
    "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';