LoginSignup
6
2

More than 5 years have passed since last update.

ZttpでシュッとHTTPリクエストを作成する

Last updated at Posted at 2017-06-05

Laravel Newsで紹介されていたので、試しに実装してみました。

インストール

$ composer require kitetail/zttp

使ってみる

  private function requestTest($uri)
  {
    $token = 'hogehoge';

    $response = Zttp::withHeaders(['Authorization' => $token])->post($uri,[
        'key' => 'value'
    ]);
    info('Test ZTTP', $response->status());
  }

deleteとかpatch、putもいける

$response = Zttp::withHeaders(['Authorization' => $token])->delete($uri);

便利!

参考

6
2
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
6
2