如何结合zend框架和Codeigniter?

2021-12-29 00:00:00 php zend-framework codeigniter

如何结合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):

  1. 身份验证

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.

  1. 安全和表单

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.

有问题吗?:)

相关文章