27
27

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.

Guzzleについてちょっと調べた

Last updated at Posted at 2014-11-03

Guzzleとは

Guzzle is a PHP HTTP client and framework for building RESTful web service clients

らしい

まぁ、いい感じのPHPのHTTPクライアントライブラリという事でしょう。

Webサーバから並行にダウンロードとかも出来るらしいから、
サーバーサイドで複数のAPIを呼ぶ時はいいのかな。

Guzzleは2つある

最新のバージョンと古いやつ

対応PHPバージョン

今回はやんごとなき事情のため、Guzzle3を使ってみる。

※パッケージ名が、Guzzle 3は「guzzle/guzzle」、Guzzle 4+は「guzzlehttp/guzzle」となっているらしいので、
注意が必要。

Guzzle3の導入

こちらにて、導入方法が書いてある。

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Guzzle as a dependency
php composer.phar require guzzle/guzzle:~3.9

composerだと導入が楽。以下のように、composer.jsonが作成される

{
    "require": {
        "guzzle/guzzle": "~3.9"
    }
}

余談だけどcomposerで何か入れるときにはcomposer.jsonを直に修正していたけど、
普通にコマンドラインで実行して入れた方が自動的にファイルを修正してくれるのでよさそう。

あたりまえかー

補足

https://github.com/aws/aws-sdk-php/blob/master/composer.json#L20
http://aws.amazon.com/jp/sdkforphp/

AWS SDK for PHPでも使われているので、(しかもGuzzle3の方)
それなりに信頼出来そうだ。

とりあえず、サンプル

何か作ろうと思ったのだが、ちょっと疲れたのでココで一旦停止。

27
27
0

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
27
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?