用于发送HTTP请求的PHP库

yxwpx 9年前

1. Unirest

unirest
Unirest is a pack of lightweight HTTP libraries for many languages (PHP, Ruby, Python, Java And Objective-C). It has support for GET, POST, PUT, UPDATE, DELETE operations and its methods + response structure are the same in all languages.

2. Requests

Requests for PHP
Requests is a stable PHP library that uses cURL or fsockopen (depending on the availability) and provides a consistent API. Requests allows you to send HEAD, GET, POST, PUT, DELETE, and PATCH HTTP requests. You can add headers, form data, multipart files, and parameters with simple arrays, and access the response data in the same way. Requests uses cURL and fsockopen, depending on what your system has available, but abstracts all the nasty stuff out of your way, providing a consistent API.

3. Guzzle

guzzle
Guzzle takes the pain out of sending HTTP requests and the redundancy out of creating web service clients. It’s a framework that includes the tools needed to create a robust web service client, including: Service descriptions for defining the inputs and outputs of an API, resource iterators for traversing paginated resources, batching for sending a large number of requests as efficiently as possible.

4. Httpful

httpful
Httpful is a simple, chainable, readable PHP library intended to make speaking HTTP sane. It lets the developer focus on interacting with APIs instead of sifting through curl set_opt pages and is an ideal PHP REST client. It comes with number of features such as custom headers, automatic payload serialization , basic auth, request templates, client side certificate auth and many more.

5. PHP VCR

php vcr
Record your test suite’s HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. It automatically records and replays HTTP(s) interactions with minimal setup. No modifications to your production code necessary, Easily configure request matching or add custom request matchers, store HTTP interactions on disk in YAML or JSON, supports PHPUnit. Recorded requests and responses can easily be inspected and edited.

6. Buzz

buzz
Buzz is a lightweight HTTP client that you can use to store and retrieve data, very well for beginners to learn more about HTTP clients and how they work in the real world.

7. Goutte

goutte
Goutte is a screen scraping and web crawling library for PHP. Goutte provides a nice API to crawl websites and extract data from the HTML/XML responses.

8. httpClient

httpclient
PHP Http Client is a fully featured HTTP client created 100% in PHP. It doesn’t use cURL or other external libraries.

9. Buzz react

buzz react
Simple async HTTP client for concurrently interacting with multiple HTTP servers, fetching URLs, talking to RESTful APIs, downloading files, following redirects etc. all at the same time.

10. Simple Http Client

simple http client
This is quite useful php library which makes simple HTTP requests from php. Thi s library is available as open source software under the MIT License.