Easy CURL for PHP

Hello all the readers,

This time its about PHP. Yes PHP ! Last project on which i was working on was on PHP. Quite many MySQL in it and quite many web requests. When it came to web requests, the only thing that was in my mind was CURL. That a good to use way to make web requests. As i was working quite after a long time on PHP, didn’t remember much of its library. Went to php.net and searched through the whole libraries and some tutorials to follow to make dummy requests to servers. It was kinda messy. I searched through net to find some wrappers for the CURL in PHP. But ! wasn’t able to find any good OOP based wrapper for CURL in PHP.

Many wrappers were there, and some were really good. But mostly all of them dealt with the underlying curl resource of PHP. Actually that was the problem, remembering all those constants was a pain for me (and i guess for many others). So i thought for a way out of this problem. MAKE MY OWN WRAPPER CLASS.

My goals were quite clear, i have to write such a wrapper that can give the strength of underlying yet be a simple one. So that the pain part can be removed. More over the result should be parsed and fetch in a properties way so that i don’t have to much working on the result to just get out the cookies or headers from it.

Getting inspiration from C# WebRequest class. I tried to create the PHP’s curl class. Please take out your time to view the Examples given with the code. And comment if you like and if you found anything missing or not properly done please report. I would be waiting for the comments.


Link to the Code Repository : Easy CURL for PHP


5 thoughts on “Easy CURL for PHP

  1. It’s a good thought to work on CURL to make it easy, I had always found CURL complicated and confusing. The source-code uploaded on github seems jumbled up at first sight. It will be nice if you organize it in folders appropriately, so that if some-one wants to use it in any framework it will be easy and just ready to integrate. Like 1 folder for libraries, 1 folder for helpers, 1 folder for Misc files and 1 folder for all-in-one package of Easy-CURL.

  2. @Usman : Thanks :)

    @Moyed : First of all thanks. And for the async thing, yes it can be async via curl multi threaded resource, but will exit the loop when all of them exits. But in my code as i have used the callback strategy, so when ever any of the pages are completely fetched, it call some callback provided at the connection initialization. I hope this is what you are talking about ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s