PHP cURL Wrapper

I’ve put up a gist of a simple PHP cURL wrapper which simplifies basic content fetching with cURL. The class throws standard Exceptions in case of no content being returned or incorrect settings being passed as arguments.


Simple setters for timeouts:

The object’s methods return the instantiated object itself to make chaining possible, for example:

Note: PHP must be compiled with the –with-curl[=DIR] flag

Update: I’ve updated the gist with changes made by Barry Parkin. Adds some extra validation as apparently FILTER_VALIDATE_URL is not to be trusted as it will let through many styles of rubbish. Additionally Barry has added an optional headers only argument to fetch:

About Ingmar Boddington

Codemonkey, Sheffield, UK
This entry was posted in PHP and tagged cURL, PHP. Bookmark the permalink.