Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple PSR compatible HTTP client library

License

NotificationsYou must be signed in to change notification settings

kwhat/requestful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable VersionLatest Unstable VersionBuild StatusTotal DownloadsLicensecomposer.lock available

Requestful: A simple PSR compatible HTTP client library

The goal of this library is to provide a short, simple and easy to understand alternative toGuzzle.

  • Uses the latestPSR standards and recommendations
  • Supports both synchronous and asynchronous HTTP requests
  • A+ Promises with a Guzzle compatible interface
  • Modern PHP 7 support
  • Hard ext-curl requirement

Installation

composer require kwhat/requestful

Usage

You will need a PSR-17 implantation to use this library. Personally I enjoy working withnyholm/psr7, but any library that provides psr/http-factory will be sufficient.

$factory =newNyholm\Psr7\Factory\Psr17Factory();$client =newRequestful\Http\Client($factory);$request =$factory->createRequest("GET","https://samples.openweathermap.org/data/2.5/weather?q=Los%20Angeles");// Send a synchronous request$response =$client->sendRequest($request);var_dump($response->getStatusCode(),// int(200)$response->getHeaderLine("content-type"),// string(30) "application/json; charset=utf8"$response->getBody()// string(459) "{"coord": {...}, "weather": {...}, ...}");// Send an asynchronous request$promise =$client->sendRequestAsync($request)    ->then(function (Psr\Http\Message\ResponseInterface$response):string {return"Success:{$response->getStatusCode()}";    });var_dump($promise->wait());// string(12) "Success: 200"

[8]ページ先頭

©2009-2025 Movatter.jp