Download the PHP package wykleph/curl without Composer
On this page you can find all versions of the php package wykleph/curl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package curl
Short Description Simple synchronous and asynchronous cURL requests in php.
License MIT
Homepage https://github.com/Wykleph/Curl
Informations about the package curl
Curler
A fluent API wrapper for libcurl in php. Setting options and headers is done using method chaining instead of setting options explicitly using the libcurl constants.
Debugging cURL commands in php using the Curler class is insanely simple as well.
Just chain the dryRun()
method onto the end of your method chain instead of
the go()
method and it will dump out all of the cURL request information
without making the request.
See http://php.net/manual/en/book.curl.php for information on libcurl.
Note: This library is in its infancy.
Full documentation coming soon.
Getting Started
Install using Composer
Add wykleph/curl
to your composer.json file or:
composer require "wykleph/curl"
You could also just copy the files in the src
directory into your project if you aren't using composer, however I would recommend it.
Creat the Curler instance.
Note that all of the following methods can be chained together unless noted otherwise
Post information
Switch From POST to a GET request
Set Headers
Set User Agent or Referer
Save Cookies
Follow Browser Redirects
Compressed Responses
You can tell Curler
you expect a compressed response from the request with compressedResponse()
.
Upload a File
Just give a form input name and a filepath.
Verbose Output
Write Response to File
multi-request support coming soon.
Preforming an Asynchronous Request, or Multi-Request
You can send asynchronous requests as well! This can be accomplished through the use of AsyncCurler by
adding URLs to the request(this retains any options that have been set in AsyncCurler up to this point),
or by adding cURL handles to the request(adding handles as opposed to urls is somewhat untested.
It's in the works though).
Debugging a request
Debug requests with ease by chaining the dryRun()
method to the end of your method chain and dumping the result.
This will output something similar to this(consider using something like Symfony's VarDumper
or Laravels dump and die - dd()
):