简体   繁体   English

如何结合zend框架和Codeigniter?

[英]How to combine zend framework and 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 ? 我有两个应用程序,一个是zend,另一个是codeigniter,是否可以将两个框架合并到一个项目中? 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. 我参与过一个项目,我们有Zend + CodeIgniter。

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. 1.将Zend文件夹(库)复制粘贴到CodeIgniter库中,或者将CodeIgniter库复制到zend库文件夹中。

2. If in codeigniter, call it using $this->load->library('Zend', '{anything here}') or in Zend use autoloader 2.如果在codeigniter中,使用$this->load->library('Zend', '{anything here}')或在Zend中使用自动加载器调用它

Issues you WILL face (which I faced): 你将面临的问题(我面临的问题):

  1. Authentication 认证

Zend uses Zend Auth Namespace which uses $_SESSION . Zend使用Zend Auth Namespace,它使用$ _SESSION。 Whereas CI does not use $_SESSION but, has it's own built in system. 虽然CI不使用$ _SESSION,但它有自己的内置系统。 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. 使用Zend和(假设您的整个应用程序仅在同一个域中)查看它为身份存储的内容,通过CI直接检查$ _SESSION并分配CI cookie。 Here is what happened with me and check the solution . 以下是我发生的事情并检查解决方案

  1. 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. CI和Zend都有不同的Forms库,不要在加载Zend Library的类中使用CI形式(在CI下),只需记住它作为一个拇指规则。 So, you need to strategize how you will implement it, Zend on CI or CI on Zend. 因此,您需要制定实施策略,Zend on CI或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). 不要在CI表格中使用Zend的验证器(我知道没有人会这样做但是,一旦我做了,所以任何人都可以做到!不要这样做)。 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. 就个人而言,我的项目做得很好(经过大量研究后),它是:Zend上的CI,我必须使用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. 就CI和Zend框架而言,Zend实际上是为了更加模块化(它本质上是一个库的集合),并且比其他方式更容易合并到CI中。

This is a common "problem" amongst those using PHP frameworks that many have solved already. 这是使用许多已经解决过的PHP框架的人们常见的“问题”。

A quick google turned up the following: 快速谷歌出现以下情况:

http://viraksun.com/tutorials/integrate-zend-library-in-code-igniter/ http://viraksun.com/tutorials/integrate-zend-library-in-code-igniter/

http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/ http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/

http://www.gotphp.com/codeigniter-with-zend-framework-libraries/54312/ 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. 您只需将“Zend”文件夹(来自Zend_Download_Folder /库)放在主“libraries”文件夹中,或放在个人应用程序/库文件夹中。

Then, from within any Controller use the loader class to load whichever Zend class you want to use. 然后,从任何Controller中使用loader类来加载您要使用的Zend类。

For Example, to use Zend_Pdf, do the following in your controller: 例如,要使用Zend_Pdf,请在控制器中执行以下操作:

//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/general/creating_libraries.html

http://codeigniter.com/user_guide/libraries/loader.html http://codeigniter.com/user_guide/libraries/loader.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM