08 July, 2010

Integrating Zend with CodeIgniter

Last day, I had to integrate Zend Framework with Codeigniter. This came out to be quite easier then i thought. So here are the steps for integrating zend
framework with codeigniter.

Step 1: Copy the Zend folder from inside the library folder of Zend Framework

Setp 2: Create a folder inside your system, such as ../system/zf.

Step 3: Create a helper file like: zf_helper.php and place it into ../system/application/helpers/
Here is the code for zf_helper.php file

//For Linux OS
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . BASEPATH . '/zf/');
require_once 'Zend/Loader.php';

//For windows OS
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . str_replace('/', '\\', BASEPATH) . 'zf\\');
require_once ('Zend/Loader.php');

Step 4: Add this helper to your ../system/application/config/autoload.php file

$autoload['helper'] = array('url', 'form', 'date', 'zf'); //zf is the helper that we have added for zend framework integration

Step 5: Now you can use any modules of Zend Framework from CodeIgniter, like in a controller file

class SomeTest extends Controller {
//in some function
function someFunction() {
//load Zend Classes
$username = "someuser@gmail.com";
$password = "somepassword";
$gCalen = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $gCalen);
$gCalen = new Zend_Gdata_Calendar($client);
//and so on

Show this is how Integrating Zend with CodeIgniter works

No comments: