All Projects → geerlingguy → Request

geerlingguy / Request

Licence: MIT license
A simple PHP HTTP request class.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Request

HttpRequest
Simplified HTTP client, A simplie golang HTTP client library.
Stars: ✭ 134 (+173.47%)
Mutual labels:  curl, request
Urllib
Request HTTP(s) URLs in a complex world
Stars: ✭ 600 (+1124.49%)
Mutual labels:  curl, request
go-axios
HTTP Request package for golang.
Stars: ✭ 29 (-40.82%)
Mutual labels:  curl, request
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (+75.51%)
Mutual labels:  curl, request
request-extra
⚡️ Extremely stable HTTP request module built on top of libcurl with retries, timeouts and callback API
Stars: ✭ 14 (-71.43%)
Mutual labels:  curl, request
Goz
A fantastic HTTP request libarary used in Golang.
Stars: ✭ 187 (+281.63%)
Mutual labels:  curl, request
ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+332.65%)
Mutual labels:  packagist
http
Aplus Framework HTTP Library
Stars: ✭ 113 (+130.61%)
Mutual labels:  request
private-packagist-api-client
Private Packagist API Client
Stars: ✭ 28 (-42.86%)
Mutual labels:  packagist
flutter curl
Flutter plugin to use libcurl for HTTP calls
Stars: ✭ 42 (-14.29%)
Mutual labels:  curl
curly.hpp
Simple cURL C++17 wrapper
Stars: ✭ 48 (-2.04%)
Mutual labels:  curl
centra
Core Node.js HTTP client
Stars: ✭ 52 (+6.12%)
Mutual labels:  request
net
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.
Stars: ✭ 16 (-67.35%)
Mutual labels:  request
cmn-utils
公共函数&请求封装
Stars: ✭ 43 (-12.24%)
Mutual labels:  request
vue-methods-promise
Let Vue methods support return Promise
Stars: ✭ 35 (-28.57%)
Mutual labels:  request
slim-mobile-detect
Implements Mobile-Detect lib for Response's write on Slim Framework App
Stars: ✭ 18 (-63.27%)
Mutual labels:  packagist
MailjetSwiftMailer
A SwiftMailer transport implementation for Mailjet
Stars: ✭ 26 (-46.94%)
Mutual labels:  packagist
grpc-curl
grpc-curl is a command line tool for interacting with gRPC servers
Stars: ✭ 59 (+20.41%)
Mutual labels:  curl
composer-velocita
Velocita - Composer plugin for transparent caching
Stars: ✭ 26 (-46.94%)
Mutual labels:  packagist
r2
A minimalist HTTP request routing helper for Go.
Stars: ✭ 32 (-34.69%)
Mutual labels:  request

Request for PHP Logo

Request

A simple PHP HTTP request class.

This class includes many convenience methods to help take the headache out of dealing with HTTP requests in PHP.

Usage

Include the class (\JJG\Request) using an autoloader, then build a new Request object, execute the request, and get the response.

$request = new Request('http://www.example.com/');
$request->execute();
$response = $request->getResponse();

Other parameters you can retrieve after executing a request include:

// The full headers from the response.
$request->getHeader();
// The latency for this response, in ms.
$request->getLatency();
// The HTTP status code (e.g. 200 for 200 OK).
$request->getHttpCode();
// Empty if no error present, otherwise shows any cURL errors.
$request->getError();

There are also other convenient methods included for other purposes.

// Returns TRUE if 'string' exists in the response.
$request->checkResponseForContent('string');

You can also make requests with basic HTTP authentication:

// Execute a request with HTTP basic authentication.
$request = new Request('http://www.example.com/secure-page');
$request->setBasicAuthCredentials('username', 'password');
$request->execute();

Other options include enabling or disabling SSL, using cookies, and setting cURL timeout values:

// Enable Cookies.
$request->enableCookies($cookie_file_path);
// Enable SSL/TLS.
$request->enableSSL();
// Set the user agent string.
$request->userAgent = 'User agent string here.';
// Set the initial connection timeout (default is 10 seconds).
$request->connectTimeout = 5;
// Set the timeout (default is 15 seconds).
$request->timeout = 10;
// Send some fields as a POST request.
$request->setRequestType('POST');
$request->setPostFields($field_array);

See the Request class variable definitions and methods for more details and documentation.

Why Request?

I've used other HTTP request libraries for PHP before, but often fall back to using cURL directly, because the libraries I've used are too complicated for my needs. This library aims to be a very simple and easy-to-use wrapper around cURL, and should be easy to pick up for anyone familiar with cURL usage in PHP.

Some other recommended HTTP libraries for PHP include:

License

Request is licensed under the MIT (Expat) license. See included LICENSE.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].