問題描述
如何結合zend框架和Codeigniter?
How to combine zend framework and Codeigniter ?
我有兩個應用程序,一個是 Zend,另一個是 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 ?
謝謝你的幫助.
推薦答案
當然有可能.
我曾參與過一個項目,其中我們同時擁有 Zend 和 CodeIgniter.
I have worked on one project where we had Zend + CodeIgniter both.
這是您需要做的:
1. 將您的 Zend 文件夾(庫)復制粘貼到 CodeIgniter 庫中,反之亦然,將 CodeIgniter 庫復制到 zend 庫文件夾中.
1. Copy paste your Zend folder (library) into Library of CodeIgniter OR viceversa copy CodeIgniter library into zend library folder.
2. 如果在 codeigniter 中,使用 $this->load->library('Zend', '{anything here}')
或在 Zend 中使用 autoloader
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):
- 身份驗證
Zend 使用使用 $_SESSION 的 Zend Auth 命名空間.而 CI 不使用 $_SESSION 但它有自己的內置系統.使用 Zend 并(假設您的整個應用程序僅在同一個域中)查看它存儲的身份信息,直接通過 CI 檢查 $_SESSION 并分配 CI cookie.這是我發生了什么并檢查解決方案.
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.
- 安全和表單
CI 和 Zend 都有不同的 Forms 庫,不要在加載 Zend 庫的類中使用 Form of CI(在 CI 下),記住這是一個經驗法則.因此,您需要制定如何實施它的戰略,Zend on CI 或 CI on Zend.不要在 CI 表單中使用 Zend 的驗證器(我知道沒有人會這樣做,但是一旦我這樣做了,那么任何人都可以這樣做!不要這樣做).使用相同的安全庫,您將用于表單的庫
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
就我個人而言,我的項目做得很好(經過大量研究),它是:Zend 上的 CI,我必須在其中使用 Zend Auth.
Personally, my project did great (ofc after lot of research), it was : CI on Zend, where I HAD to use Zend Auth.
有問題嗎?:)
這篇關于如何結合zend框架和Codeigniter?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!