5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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

環境

  • Ubuntu 14.04.1 LTS
  • x86_64
  • PHP回りは何も入ってない状態

流れ

PHPを入れる

$ sudo apt-get install php5-cli

cliのみの最低限で。

Composerを入れる

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

どこでも使えるように、/usr/local/bin/下に移動。

$ composer --version
Composer version 1.0-dev (b23a3cd36870ff0eefc161a4638d9fcf49d998ba) 2014-11-21 17:59:11

動いた。

AWS SDKのサンプルを拾ってくる

$ git clone https://github.com/awslabs/aws-php-sample.git

cloneするだけ。

いざcomposer install

$ 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に追記してみる

{
    "require": {
        "guzzle/guzzle": "3.9.*",
        "aws/aws-sdk-php": "2.6.*"
    }
}

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

$ 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の拡張を入れる

$ 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

めでたしめでたし。

よく見たら

ここに、

PHP 5.3.3+ compiled with the cURL extension

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

5
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?