OOCurl
I've always been bothered by the PHP cURL library. It feels very old and, while definitely functional, doesn't really "fit in" with more modern, object-oriented software.
So, I wrote this small class to provide an OO interface to the cURL library. It's not a PHP Extension, it doesn't replace the cURL library, but it will let you use cURL in a way that doesn't seem so out of place.
No, this is not the world's most useful library, but it also wasn't very much work, so, there you go.
Installation
Download or check out OOCurl. Include the file OOCurl.php
in your script. Use.
Using OOCurl
OOCurl is just an object-oriented wrapper for the PHP cURL functions. If you are familiar with them, you should be fine with OOCurl. There are, however, two major differences.
First, instead of using a function like curl_setopt,
OOCurl lets you set properties via the assignment operator =.
For example, if you wanted to include headers in the output, without OOCurl,
you would have to do this:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, true);
?>
With OOCurl, though, you can just assign the header member
of the Curl object to true:
<?php
require_once 'OOCurl.php';
$curl = new Curl;
$curl->header = true;
?>
To set any option, take the second half of the CURLOPT_*
constant (eg: header above). The underscores are the same,
but they are not case sensitive.
The other difference is the default setting of CURLOPT_RETURNTRANSFER.
Since the vast majority of cases I've seen set this to true,
the default value in OOCurl is true. If you need the
usual passthrough, you'll have to set it back to false.
License
OOCurl is "show me"-ware. If you decide to use it, please let me know so I can see my handiwork in action! Other than that, it's under the MIT License.
Download OOCurl
To get the latest version, you should check OOCurl from SVN:
svn://jamessocol.com/oocurl/trunk
You can check out the tags directory for specific versions.
You can also download the plugin in a ZIP file. (Current ZIP version: 0.2.1)
Feedback
Please leave a comment or email me if you use OOCurl, or if you try to use it and hate it, or if it kills your dog. I'm not going to bring your dog back to life, but I'd love to hear your feedback.