There seems to have been previous attempts to integrate Zend with Symfony in the same project. I hear it can be done and has been done, but aside from a slide show linked below, the actual video accompanying the slide show is not freely available.
So does anyone know of good resources that explain such integration well? blogs, videos, whatever. I'll add whatever you post here for easier access to others in the future.
Resources I've found so far:
this text slide show
Edit: I should add if you've done this
yourself before, can you also please
post any tips (as little or lots) to
help those who may want to try it.
It is completely simple to add the Zend framework to run in Symfony. There are certain components of the Zend framework that compliment the Symfony framework. I am currently using Zend for the Lucene Search, as well as their Mailer.
To use Zend in Symfony, you just need to do two things:
Copy the Zend framework to your /lib/vendor/ folder.
Modify the ProjectConfiguration file. (config/ProjectConfiguration.class.php)
class ProjectConfiguration extends sfProjectConfiguration
{
static protected $zendLoaded = false;
static public function registerZend()
{
if (self::$zendLoaded) { return; }
set_include_path(sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path());
require_once sfConfig::get('sf_lib_dir').'/vendor/Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
self::$zendLoaded = true;
}
}
All this can be found in the Symfony tutorial here:
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/17
From the discussion above:
I was thinking to use Symfony as the base + Zend components as needed. So I will be using Symfony's folder structure but none of Zend's bootstrap and ini.
From my experience with ZF I would say, this can definitely be done and is worth simply getting started with.
You'll have to haggle with Autoloading a bit (you should probably load all Zend related includes manually and not use its autoloader at all) but other than that, I can't see any problems. (disclaimer: I don't know Symfony in depth at all and can't comment on possible namespace collisions, but seeing as Zend was built to avoid those, and Symfony is a mature framework, I don't think you'll encounter anything impossible.)
If you're using Symfony as your top-level framework, it's trivial.
In fact, integrating a Zend Framework component even used to be part of the standard symfony tutorial.
Related
I've got some php code handling emails (not self written) which I want to integrate in my own self written system. In it, two Classes are used:
Zend_Mail_Storage_Pop3($params)
Zend_Mail_Storage_Imap($params)
I've heard of Zend before, but as far as I know it is some kind of full fledged php framework, not something I really what to incorporate in my system just to be able to use these two classes. So I downloaded Zend from the github page, but I can't even find those classes in there.
So my questions are:
Am I able (and if so, how?) to just use these two classes from Zend?
If not, is there an alternative to these two classes which are preferably very easy to use?
All tips are welcome!
It's hard to answer this question without knowing exactly what you want to do (you've just said what classes you think might achieve that goal), but hopefully I can point you in the right direction.
Zend Framework is a full PHP framework, but it was built as a collection of libraries, and to a certain extent you can just cherry pick individual components and only use those. The two classes you listed were from Zend Framework 1. What you downloaded from Github was Zend Framework 2, which is why you can't find them, but ZF2 does have equivalents.
Although you could download ZF1 and get your existing code to work, what I'd suggest you do instead is add just the ZF2 Mail component to your app using Composer. Then start here: http://framework.zend.com/manual/2.3/en/modules/zend.mail.read.html for the docs for the equivalent classes for what I'm guessing you're trying to do.
I have an project that is used by many users and it's written in Codeigniter. I'm very happy with my application but I'm getting lost with Codeigniter because of the functionality of the framework and my application is getting too big for Codeigniter (that is what I think).
I want to go from Codeigniter to Zend, but the application is too big to begin all over again because there is still more functionality to come.
I don't know if someone has experienced or tried it, but does anybody know if it is possible to integrate Codeigniter into Zend as an module and migrate in steps to the Zend Framework 2?
Sorry for my bad english by the way :-)
Having experience with small and medium-scale projects with both CodeIgniter (CI) and Zend Framework (ZF), I can tell you that using one framework over the other will not solve any problem you might be having.
If you are looking for the added functionality provided by the ZF components, such as a ready-made class for Date or the Form verification class, know that you can use ZF components in Code Igniter. You will need to create a special class in CI that will jumpstart the ZF class autoloader. From there you can simply include ZF classes and use them as if you were inside a ZF application.
See http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/ and http://fr.slideshare.net/samsonasik/codeigniter-using-third-party-components-zend-framework-components for more details.
"Integrate" means you want to put your app running on CodeIgniter withing ZendFramework. So basically you changed nothing and there's no much sense of doing so.
You perhaps could consider porting your app from CI to ZF, but that will require rewriting of your code. But I'd first try to find out what the bottleneck in your app really is and ensure that you will benefit from the switch
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
Zend framework is well known for loosely coupled components.
I would like to use XML-RPC from zend framework, is there any dependency for XML-RPC? Like if I had taken out XML-RPC folder off Zend Framework Library and try to instantiate RPC object, would it throw error?
Where can I find the proper way of separating component from the framework?
Thanks
I wrote a tool which takes ZF components and their dependencies so you can easily take just one (or several) component from ZF.
http://epic.codeutopia.net/pack/
It doesn't have the latest ZF release 1.11 (because I'm lazy), but 1.10.6 should work just fine.
You should never split single components off a framework or library independent from Zend Framework, or any other. Especially when using PHP there is also no performance reason, because with PHPs autoloading functionality it will always just include the files, which are requested.
You should literally be able to copy the XmlRpc folder from your copy of Zend Framework and use it in your own projects. The only dependency that I can see is in XmlRpc/Exception.php as it requires a file in the root directory of Zend/ (Exception.php) you could simply copy this file along with the XmlRpc folder keeping the directory structure the same and it should work....
My first question is why you would want to do that in the first place. It means that every time you upgrade Zend Framework you now need add a bunch of tooling to manage the removal of some components. One of the purposes of using a framework is so you don't have to manage a bunch of code. Removing parts of a framework is a step backwards IMHO. Disk space is cheap. Network transfer is cheap. If you are going to remove parts of a framework you should have a REALLY, REALLY good reason to do it.
Do you know others frameworks like PEAR (http://pear.php.net) ? I want to use reusable PHP components without using the famous PEAR.
I already use a framework (Zend Framework) and i want to use php components who doesn't exists in ZF like payment, encryption, math...
Check out EZ Components. It is a very loosly coupled set of libraries that I always see as sitting somewhere between something like PEAR and Zend Framework. Superbly coded and up to date, it is something to take a close look at.
I don't really do that much php, but I've worked along side php developers for some time and I've heard comparisons between PEAR, SMARTY and Zend Framework all the time. I can't really tell you how much alike they are, but these are the ones I've heard about the most. I've also heard some saying they work with Cake PHP or Symfony, but not as many.
I also found two nice comparisons that might help, here and here. That's about all the help I can be. Good luck. :)
As a Zend Framework fan myself I don't see why you don't extend Zend Framework based to your needs. I use a rather simple method by having a classes folder inside my application folder which you need to set up in bootstrap or load with Zend_Loader and there you can define your own logic or import different modules you're interested in ( phpClasses might be also very helpful).
You also can find a lot of helpers made by Zend Framework's community which might be helpful at any given time. If you like to go and strip off pieces of code from different sources you might also want to try to import some of the modules from other frameworks like Code Igniter or CakePhp into Zend Framework and that probably would be a fun and useful thing for you and if you'd like to share, maybe for all the community based around ZF
And I should warn you about Symfony (that evilpenguin wrote about), if you're willing to try it just don't forget it's the "laziest" of them all.