yii-curl curl wrapper for yii

Curl Wrapper for Yii framework

  1. GitHub url
  2. Requirements
  3. Setup instructions
  4. Usage

GitHub url

Yii Curl extension on github (https://github.com/hackerone/curl/)

please download the file from github.

Requirements

  • PHP 5.2+
  • Yii 1.1.7 (should work on older versions too)
  • Curl and php-curl installed

Setup instructions

  • Place Curl.php into protected/extensions folder of your project
  • in main.php, add the following to 'components':
php
	'curl' => array(
			'class' => 'ext.Curl',
			'options' => array(/.. additional curl options ../)
		);

Usage

  • to GET a page with default params
php
	$output = Yii::app()->curl->get($url, $params);
	// output will contain the result of the query
	// $params - query that'll be appended to the url
  • to POST data to a page
php
	$output = Yii::app()->curl->post($url, $data);
	// $data - data that will be POSTed

  • to PUT data
    php
      $output = Yii::app()->curl->put($url, $data, $params);
      // $data - data that will be sent in the body of the PUT
    

* to set options before GET or POST or PUT

php

$output = Yii::app()->curl->setOption($name, $value)->get($url, $params);
// $name & $value - CURL options
$output = Yii::app()->curl->setOptions(array($name => $value))->get($get, $params);
// pass key value pairs containing the CURL options

### changelog
v 1.2
* added PUT option
8 0
18 followers
0 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Networking
Tags: CURL, get, http, post, put
Developed by: hackerone
Created on: Oct 4, 2012
Last updated: 11 years ago

Related Extensions