Download the PHP package powderblue/curl without Composer
On this page you can find all versions of the php package powderblue/curl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download powderblue/curl
More information about powderblue/curl
Files in powderblue/curl
Package curl
Short Description A basic CURL wrapper for PHP. This is a modernised, and maintained, version of @shuber's rather nice, simple cURL wrapper, https://github.com/shuber/curl.
License MIT
Informations about the package curl
Curl
A basic cURL wrapper for PHP.
:information_source: See https://www.php.net/curl for more information about the cURL extension for PHP
This fork is a modernised, and maintained, version of @shuber's rather nice, simple cURL wrapper.
Installation
Use Composer.
Usage
Initialization
Simply require and initialize the Curl
class like so:
Performing a Request
The Curl
class provides shortcuts for making requests using the HEAD
, GET
, POST
, PUT
, and DELETE
methods. You must always specify a URL; you can also pass an array/string of variables to send along with it, if need be.
Use Curl::request()
to make a request using a custom request-method, thus:
Examples:
All requests return an instance of PowderBlue\Curl\Response
if successful, or throw an exception if an error occurs.
The Response Class
A normal cURL request returns the headers and body in a single string. The PowderBlue\Curl\Response
class splits that string, placing the two parts in separate properties.
For example:
Would display something like:
:information_source:
PowderBlue\Curl\Response::__toString()
returns the response body, so—for example—echo $response
will output the same asecho $response->body
.
Cookies/Sessions
By default, cookies will be stored in <lib-dir>/var/curl_cookie.txt
. You can change this by doing something like the following.
This allows you to maintain a session across requests.
Basic Configuration Options
You can easily set the referer or user-agent:
Setting Headers
You can specify headers to send with the request:
Setting Custom cURL Request Options
By default, redirects will be followed. You can disable this with:
If you need to do something a little more exotic, you can set/override cURL options like this:
:information_source: See the
curl_setopt()
documentation for a list of cURL request options
Get in Touch
Problems, comments, and suggestions are all welcome: [email protected].
All versions of curl with dependencies
ext-curl Version *