Download the PHP package alioygur/curl without Composer
On this page you can find all versions of the php package alioygur/curl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alioygur/curl
More information about alioygur/curl
Files in alioygur/curl
Informations about the package curl
Curl
A basic CURL wrapper for PHP (see http://php.net/curl for more information about the libcurl extension for PHP)
Installation
This library is available via Composer
Usage
Simple example of usage
Simply initialize and usage the Curl
class like so:
Performing a Request
The Curl object supports 5 types of requests: HEAD, GET, POST, PUT, and DELETE. You must specify a url to request and optionally specify an associative array or string of variables to send along with it.
To use a custom request methods, you can call the request
method:
All of the built in request methods like put
and get
simply wrap the request
method. For example, the post
method is implemented like:
Examples:
All requests return a CurlResponse object (see below) or false if an error occurred. You can access the error string with the $curl->error()
method.
The CurlResponse Object
A normal CURL request will return the headers and the body in one response string.
The CurlResponse class defines the magic __toString() method which will return the response body, so echo $response
is the same as echo $response->body
Cookie Sessions
By default, cookies will be stored in a file called curl_cookie.txt
. You can change this file's name by setting it like this
This allows you to maintain a session across requests
Setting Custom Headers
You can set custom headers to send with the request
Setting Custom CURL request options
By default, the Curl
object will follow redirects. You can disable this by setting:
You can set/override many different options for CURL requests (see the curl_setopt() documentation for a list of them)
Auth
Sets the user and password for HTTP auth basic authentication method.
Contact
Problems, comments, and suggestions all welcome: [email protected]