尽管没有对composer.json

时间:2015-05-28 10:23:15

标签: amazon-web-services composer-php elastic-beanstalk

我在AWS Elastic Beanstalk中运行了许多环境。我使用git aws.push直接从git部署。

我使用composer.json安装所需的php sdk。我很长一段时间没有改变这个文件,但它突然在所有环境中都失败了。

AWS日志的输出

+ echo 'Found composer.json file. Attempting to install vendors.'
Found composer.json file. Attempting to install vendors.
+ composer.phar install --no-ansi --no-interaction
Loading composer repositories with package information
Installing dependencies



  [RuntimeException]                                                                                                                                                 
  Could not load package aws/aws-sdk-php in http://packagist.org:     [UnexpectedValueException] Could not parse version constraint ^5.3:     Invalid version string "^5.3"  






  [UnexpectedValueException]                                              
  Could not parse version constraint ^5.3: Invalid version string "^5.3"  



install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]



2015-05-28 09:57:18,414 [ERROR] (15056 MainThread)     [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script     /opt/elasticbeanstalk/hooks/appdeploy/pre/10_composer_install.sh failed     with returncode 1

我的composer.json是:

{
"require": {
    "aws/aws-sdk-php": "2.7.*",
    "monolog/monolog": "1.0.*",
    "facebook/php-sdk-v4" : "4.0.*",
    "ext-curl": "*",
    "paypal/sdk-core-php": "v1.4.2",
    "paypal/permissions-sdk-php":"v2.5.106",
    "paypal/adaptivepayments-sdk-php":"2.*"
}
}

我注意到它确实需要aws-sdk-php,但版本不是5.3(在日志中提到)。

5.3让我觉得php版本,检查php -v我得到

php -v
PHP 5.5.12 (cli) (built: May 20 2014 22:27:36)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend     Technologies

我已经尝试重新安装以前安装得很好的旧版本,但它们也会因同样的错误而失败。这必须归功于环境。有谁知道最近是否有变化。

2 个答案:

答案 0 :(得分:9)

在项目的根目录中创建一个名为.ebextensions的文件夹。然后在其中创建一个名为01-composer-install.config的新文件,其中包含以下内容。

commands:
  01_update_composer:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root

答案 1 :(得分:0)

我只需要使用以下说明更新作曲家: https://getcomposer.org/download/