aws sdk for phpをインストールするならcomposerでしょ!
TRANSCRIPT
Composer@slywalker (Yasuo Harada)
のインストールならAWS SDK for PHP
でしょ!
about me
大阪でAWS+PHP(CakePHP)+MySQLを主に使って開発を行っています。
@slywalker
@slywalkerfollow me!
github.com/slywalker
github.com/slywalkerfork me!
PHPエンジニア養成読本
PHPエンジニア養成読本buy now!
Composerを使ったほうがいいのか?
なぜ?
AWS SDK for PHP 2 を使用して、AWS の使用を迅速に開始します。この SDK は、Amazon S3、Amazon Glacier、DynamoDB、CloudFront など、多くの AWS サービス向けの Ruby クラスを提供するため、コーディングの複雑さが軽減されます。ダウンロード可能な 1 つのパッケージに、AWS PHP ライブラリとドキュメントが含まれます。
AWS SDK for PHPhttp://aws.amazon.com/jp/sdkforphp/ より引用(原文まま) 2013年9月27日現在
インストール方法はいくつかある
AWS SDK for PHP
Zip or Phar
Pear
Composer & Packagist
Zip or Phar
バージョン管理は目視、手動
バグフィックスなど追いかける手間
呼び出しは、ファイルをrequire
Zip or Phar
救い?CUIでの操作が不要
どこでも好きなところに設置OK
だがそれが不幸の原因に!?
Zip or Phar
なにもかもが手動
Zip or Phar
安宅船
なにもかもが手動
Zip or Phar
安宅船
なにもかもが手動
手漕ぎ!!
バージョン管理OK
でも、依存性解消までは無理
呼び出しは、pearのディレクトリをinclude_pathに設定
いままで本当にありがとう!
Pear
1サーバ=1バージョン
ひとつの環境上で複数アプリを違ったバージョンで運用できない
複数運用しようとZipへ逆戻り…
いままで本当にありがとう!
Pear
華々しい戦績も…
Pear
重巡愛宕
華々しい戦績も…
Pear
重巡愛宕
華々しい戦績も…
轟沈!!
Pear
バージョン管理OK
アプリごとに別バージョンOK
依存性解消OK
呼び出しは、autoloader
Composer & Packagist
Composer & Packagist
最新鋭
護衛艦あたご
Composer & Packagist
最新鋭
操作 バージョン管理 インストール先 呼び出し
GUI なし アプリ require
CUI あり(依存性解消なし)
環境 include_path
CUI あり(依存性解消あり)
アプリ autoloader
One more thing...
どうしてこうなった…
git clone or git submodule
どうしてこうなった…
git clone or git submodule
どうしてこうなった…
git clone or git submodule
何これ!!
Composer依存性解消のしくみ
実録
$ vim composer.json
{ "require": { "aws/aws-sdk-php": "2.*" }}
$ php composer.phar install
Loading composer repositories with package informationInstalling dependencies (including require-dev) - Installing symfony/event-dispatcher (v2.3.5) Downloading: 100%
- Installing guzzle/guzzle (v3.7.3) Loading from cache
- Installing aws/aws-sdk-php (2.4.6) Loading from cache
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 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 fileGenerating autoload files
Loading composer repositories with package informationInstalling dependencies (including require-dev) - Installing symfony/event-dispatcher (v2.3.5) Downloading: 100%
- Installing guzzle/guzzle (v3.7.3) Loading from cache
- Installing aws/aws-sdk-php (2.4.6) Loading from cache
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 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 fileGenerating autoload files
依存関係にあるパッケージが
インストールされる
Loading composer repositories with package informationInstalling dependencies (including require-dev) - Installing symfony/event-dispatcher (v2.3.5) Downloading: 100%
- Installing guzzle/guzzle (v3.7.3) Loading from cache
- Installing aws/aws-sdk-php (2.4.6) Loading from cache
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 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 fileGenerating autoload files
依存関係にあるパッケージが
インストールされるaws-sdk-php (2.4.6)guzzle(3.7.3)
$ vim composer.json
{ "require": { "aws/aws-sdk-php": "2.*", "guzzle/guzzle": "3.6.*" }}
$ php composer.phar update
アプリがguzzle(3.6)までの対応だった場合
Loading composer repositories with package informationUpdating dependencies (including require-dev) - Removing guzzle/guzzle (v3.7.3) - Installing guzzle/guzzle (v3.6.0) Loading from cache
- Removing aws/aws-sdk-php (2.4.6) - Installing aws/aws-sdk-php (2.3.4) Loading from cache
Writing lock fileGenerating autoload files
Loading composer repositories with package informationUpdating dependencies (including require-dev) - Removing guzzle/guzzle (v3.7.3) - Installing guzzle/guzzle (v3.6.0) Loading from cache
- Removing aws/aws-sdk-php (2.4.6) - Installing aws/aws-sdk-php (2.3.4) Loading from cache
Writing lock fileGenerating autoload files
設定されたバージョンの範囲内でインストールされる
Loading composer repositories with package informationUpdating dependencies (including require-dev) - Removing guzzle/guzzle (v3.7.3) - Installing guzzle/guzzle (v3.6.0) Loading from cache
- Removing aws/aws-sdk-php (2.4.6) - Installing aws/aws-sdk-php (2.3.4) Loading from cache
Writing lock fileGenerating autoload files
設定されたバージョンの範囲内でインストールされるaws-sdk-php (2.3.4)guzzle(3.6.0)
$ vim composer.json
{ "require": { "aws/aws-sdk-php": "2.4.*", "guzzle/guzzle": "3.6.*" }}
$ php composer.phar update
バージョンの組み合わせが存在しない場合
Loading composer repositories with package informationUpdating dependencies (including require-dev)Your requirements could not be resolved to an installable set of packages.
Problem 1 - Conclusion: don't install aws/aws-sdk-php 2.4.6 - Conclusion: don't install aws/aws-sdk-php 2.4.5 - Conclusion: don't install aws/aws-sdk-php 2.4.4 - Conclusion: don't install aws/aws-sdk-php 2.4.3 - Conclusion: don't install aws/aws-sdk-php 2.4.2 - Conclusion: don't install aws/aws-sdk-php 2.4.1 - Conclusion: don't install guzzle/guzzle v3.7.3 - Installation request for aws/aws-sdk-php 2.4.* -> satisfiable by aws/aws-sdk-php[2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6]. - Conclusion: remove guzzle/guzzle v3.6.0 - aws/aws-sdk-php 2.4.0 requires guzzle/guzzle ~3.7.0 -> satisfiable by guzzle/guzzle[v3.7.0, v3.7.1, v3.7.2, v3.7.3]. - Can only install one of: guzzle/guzzle[v3.7.0, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.1, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.2, v3.6.0]. - Installation request for guzzle/guzzle 3.6.* -> satisfiable by guzzle/guzzle[v3.6.0].
Loading composer repositories with package informationUpdating dependencies (including require-dev)Your requirements could not be resolved to an installable set of packages.
Problem 1 - Conclusion: don't install aws/aws-sdk-php 2.4.6 - Conclusion: don't install aws/aws-sdk-php 2.4.5 - Conclusion: don't install aws/aws-sdk-php 2.4.4 - Conclusion: don't install aws/aws-sdk-php 2.4.3 - Conclusion: don't install aws/aws-sdk-php 2.4.2 - Conclusion: don't install aws/aws-sdk-php 2.4.1 - Conclusion: don't install guzzle/guzzle v3.7.3 - Installation request for aws/aws-sdk-php 2.4.* -> satisfiable by aws/aws-sdk-php[2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6]. - Conclusion: remove guzzle/guzzle v3.6.0 - aws/aws-sdk-php 2.4.0 requires guzzle/guzzle ~3.7.0 -> satisfiable by guzzle/guzzle[v3.7.0, v3.7.1, v3.7.2, v3.7.3]. - Can only install one of: guzzle/guzzle[v3.7.0, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.1, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.2, v3.6.0]. - Installation request for guzzle/guzzle 3.6.* -> satisfiable by guzzle/guzzle[v3.6.0].
頑張って組み合わせをさがしてみた結果
Loading composer repositories with package informationUpdating dependencies (including require-dev)Your requirements could not be resolved to an installable set of packages.
Problem 1 - Conclusion: don't install aws/aws-sdk-php 2.4.6 - Conclusion: don't install aws/aws-sdk-php 2.4.5 - Conclusion: don't install aws/aws-sdk-php 2.4.4 - Conclusion: don't install aws/aws-sdk-php 2.4.3 - Conclusion: don't install aws/aws-sdk-php 2.4.2 - Conclusion: don't install aws/aws-sdk-php 2.4.1 - Conclusion: don't install guzzle/guzzle v3.7.3 - Installation request for aws/aws-sdk-php 2.4.* -> satisfiable by aws/aws-sdk-php[2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6]. - Conclusion: remove guzzle/guzzle v3.6.0 - aws/aws-sdk-php 2.4.0 requires guzzle/guzzle ~3.7.0 -> satisfiable by guzzle/guzzle[v3.7.0, v3.7.1, v3.7.2, v3.7.3]. - Can only install one of: guzzle/guzzle[v3.7.0, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.1, v3.6.0]. - Can only install one of: guzzle/guzzle[v3.7.2, v3.6.0]. - Installation request for guzzle/guzzle 3.6.* -> satisfiable by guzzle/guzzle[v3.6.0].
頑張って組み合わせをさがしてみた結果
インストール失敗
$ vim composer.json
{ "require": { "aws/aws-sdk-php": "2.*", "guzzle/guzzle": "2.*" }}
$ php composer.phar update
バージョンの組み合わせの範囲が広いと…
Loading composer repositories with package informationUpdating dependencies (including require-dev)
Loading composer repositories with package informationUpdating dependencies (including require-dev)
なかなか終わらない…
{ "require": { "aws/aws-sdk-php": "2.4.*", "guzzle/guzzle": "3.7.*" }}
開発で使用するときはマイナーバージョンまで指定しておいたほうがいいかも
Composer使うべき最大の理由?!
そして
公式ドキュメント
http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/installation.html
冒頭で解説!!Composer
amazon様が
使えと!!
Composer
ありがとうございます