LazyCurl

A PHP class which brings back @-prefix usage in CURL requests to live, even in PHP 7. http://lazycurl.net/

Download ZIP File | Download TAR Ball | View On GitHub

LazyCurl

A PHP class which brings back @-prefix usage in CURL requests to live, even in PHP 7. http://lazycurl.net/

About

The PHP CURL library is an extremely powerful tool supporting a wide range of protocols. Yet it may be too powerful that there are over 140 customizable options and some of them are affecting one another. LazyCurl is developed to provide an easy-to-use interface for most HTTP requests.

The @-prefix usage in PHP CURL was once a handy method for uploading file in HTTP POST requests. It was deprecated as of PHP 5.5 for various reasons. LazyCurl provides a secure approach in using @-prefix and extends its capability from local file to HTTP URL.

Features

How To Use @-prefix With LazyCurl

For example, if you want to upload some files with form data:

<?php
	$fields = array(
		'username' => 'John Smith',
		'email' => 'john.smith@example.com',
		'photo' => '@/local/path/photo.jpg',
		'application' => '@http://example.com/user/john.smith/signed.pdf',
		'twitter' => '@john.smith.does.not.exist'
	);
	$files = array(
		'@/local/path/photo.jpg',
		'@http://example.com/user/john.smith/signed.pdf'
	);
	$curl = new LazyCurl();
	$curl->exec('https://example.com/path/to/target.php', 'POST', $fields, $files);
	$curl->close();
?>

That’s it. The target PHP will receive text fields ‘username’, ‘email’ and ‘twitter’, together with 2 uploaded files.

System Requirement

Tested Environment

Examples

LazyCurl comes with 6 examples to show you how to use all 11 methods in different scenarios. Simply upload to web server and open in browser to see them in live.

Notes

Additional notes are embedded in the PHP class. It is strongly recommended you read them carefully to fully understand its capabilities and limitations.

License

The contents of this repository is released under the MIT license.