ゼロからAWS SDK for PHPを動かせるようになるまで

何もない状態からComposer( http://getcomposer.org/ )でAWS SDK( http://aws.amazon.com/jp/sdkforphp/ )を入れて動かそうとしたら変なところで詰まってしまったので、備忘録として。

## 環境
 * Ubuntu 14.04.1 LTS
 * x86_64
 * PHP回りは何も入ってない状態

## 流れ
### PHPを入れる
```bash
$ sudo apt-get install php5-cli
```
cliのみの最低限で。

### Composerを入れる
```bash
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
```
どこでも使えるように、/usr/local/bin/下に移動。

```bash
$ composer --version
Composer version 1.0-dev (b23a3cd36870ff0eefc161a4638d9fcf49d998ba) 2014-11-21 17:59:11
```
動いた。

### AWS SDKのサンプルを拾ってくる
```bash
$ git clone https://github.com/awslabs/aws-php-sample.git
```
cloneするだけ。

### いざcomposer install
```bash
$ composer installLoading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
(略)
    - aws/aws-sdk-php 2.6.16 requires guzzle/guzzle >=3.7.0,<=3.9.9 -> satisfiable by guzzle/guzzle[v3.7.0, v3.7.1, v3.7.2, v3.7.3, v3.7.4, v3.8.0, v3.8.1, v3.9.0, v3.9.1, v3.9.2].
(略)
```
依存関係が解決できないようだけど、勝手に入れてくれたような・・・？

#### composer.jsonに追記してみる
```json
{
    "require": {
        "guzzle/guzzle": "3.9.*",
        "aws/aws-sdk-php": "2.6.*"
    }
}

```
Guzzleの依存関係が解決できてないっぽいので、追記して再度`composer intall`してみると・・・

```bash
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - guzzle/guzzle v3.9.2 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    - guzzle/guzzle v3.9.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    - guzzle/guzzle v3.9.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    - Installation request for guzzle/guzzle 3.9.* -> satisfiable by guzzle/guzzle[v3.9.0, v3.9.1, v3.9.2].
```
curlの拡張を入れないといけなかったらしい。

#### curlの拡張を入れる
```bash
$ sudo apt-get install php5-curl
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing symfony/event-dispatcher (v2.6.0)
    Downloading: 100%         

  - Installing guzzle/guzzle (v3.9.2)
    Downloading: 100%         

  - Installing aws/aws-sdk-php (2.6.16)
    Downloading: 100%         

symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
aws/aws-sdk-php suggests installing doctrine/cache (Adds support for caching of credentials and responses)
aws/aws-sdk-php suggests installing ext-apc (Allows service description opcode caching, request and response caching, and credentials caching)
aws/aws-sdk-php suggests installing monolog/monolog (Adds support for logging HTTP requests and responses)
aws/aws-sdk-php suggests installing symfony/yaml (Eases the ability to write manifests for creating jobs in AWS Import/Export)
Writing lock file
Generating autoload files
```
めでたしめでたし。

## よく見たら
[ここ](http://docs.aws.amazon.com/aws-sdk-php/guide/latest/requirements.html)に、
> PHP 5.3.3+ compiled with the cURL extension

と書いてありました。ドキュメントをよく読みましょう・・・。