How to combine zend framework and Codeigniter ?
I have two applications, one is zend and other one is codeigniter, is it possible to combine the two framework in to one project ? If so, How to combine the two framework and what are the files structure for this ?
Thank you for you help.
Ofcourse it is possible.
I have worked on one project where we had Zend + CodeIgniter both.
Here is what you need to do:
1. Copy paste your Zend folder (library) into Library of CodeIgniter OR viceversa copy CodeIgniter library into zend library folder.
2. If in codeigniter, call it using $this->load->library('Zend', '{anything here}')
or in Zend use autoloader
Issues you WILL face (which I faced):
- Authentication
Zend uses Zend Auth Namespace which uses $_SESSION . Whereas CI does not use $_SESSION but, has it's own built in system. Use Zend and (assuming your entire app is on same domain only) see what it stores for identity, check for that $_SESSION directly via CI and assign CI cookies. Here is what happened with me and check the solution.
- Security and Forms
Both CI and Zend have different libraries for Forms, do not use Form of CI in the class which loads Zend Library (under CI), just remember this as a thumb-rule. So, you need to strategize how you will implement it, Zend on CI or CI on Zend. Do not use validators of Zend in CI forms (I know no one will do it but, once I did, so anyone can do it! DONT DO IT). Use same library of security which library you will use for forms
Personally, my project did great (ofc after lot of research), it was : CI on Zend, where I HAD to use Zend Auth.
Questions? :)
As far as combining frameworks go its typically best to stick with one framework's ideology. Otherwise, why use that framework? Save for specific pieces of functionality.
As far as CI and Zend Framework go, Zend was actually built to be more modular (its essentially a collection of libraries anyway) and would be significantly easier to incorporate into CI than the other way around.
This is a common "problem" amongst those using PHP frameworks that many have solved already.
A quick google turned up the following:
http://viraksun.com/tutorials/integrate-zend-library-in-code-igniter/
http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/
http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/
To answer your question more directly:
You could simply place the "Zend" folder (from Zend_Download_Folder/library)
in the main "libraries" folder, or within your personal application/libraries folder.
Then, from within any Controller use the loader class to load whichever Zend class you want to use.
For Example, to use Zend_Pdf, do the following in your controller:
//load it
$this->load->library('Zend/Pdf');
//use it
$zendPdf = new Zend_Pdf();
$zendPdf->someMethod();
Source:
http://codeigniter.com/user_guide/general/creating_libraries.html
http://codeigniter.com/user_guide/libraries/loader.html