Joomla and Zend: creating joomla component in Zend Framework
Posted by Faheem Abbas on May 15, 2009
Joomla is a nice CMS(content management system) and Zend Framework is once of the famous and widely adopted MVC Framework since its first release. One of the nice thing about Zend is its loosely coupled components.
Keep in mind that component in joomla and Zend Framework don’t refer to the same concept. Those who have worked in Joomla and Zend Framework know the difference.
In this article I’m not going to discuss what Zend and Joomla are all about and how component is different in both, but instead I’m going to share a little secret of how to develop joomla component in Zend Framework.
This article is not for those who are unaware of joomla and Zend.
Although joomla has own API for developing its components and modules, but you can use any php code in addition to its own API.
Reason is simple. Joomla is developed in php.
As Zend also used php behind the scene, so both can interact easily.
This was a bit of introduction.
While discussing all these things I assumed that you have little knowledge of joomla and have some knowledge of Zend Framework as well.
So let’s dig in.
Before writing any code you will need to successfully download and install joomla. Also download Zend and save it in the directory of your choice.
Once successfully installed joomla, open joomla/administrator/components and create a folder called com_yourcomp.
This is your component folder. You will need to create a file named yourcomp.php
If you want to add component in your administrator, the name should be admin.yourcomp.php.
That’s it, you have now created a the necessary directory structure for your joomla component development.
If you write a line “Hello world!” in youcomp.php or admin.yourcomp.php and browse your page as
http://localhost/joomla/index.php?option=com_yourcomp
you will see
“Hello world” printed.
These are the minimum requirements for developing joomla component.
Now we will using Zend Framework classes to add code to this file plus we will create Zend directory structure in order to work with Zend MVC.
Create following directory structure in your joomla/administrator/components.

gabriel solomon said
verry cool article, and a verry interesting ideea to combine joomla and zend.
Once you get used to using Zend, coding without it seems a little strange, and i for once always seem look on how can i add this same logic from zend here
Peter said
nice
James said
Would this same concept work with multiple ZF-based controllers? How do you reconcile the URL routing differences between Joomla (index.php?option=com_component&task=edit) and ZF (index/edit) once you’re inside the ZF-based Joomla component? In other words, once POST processing is done within the ZF component, how do you route back to Joomla’s front controller?
Faheem Abbas said
Well James, if you have read the entire article, you may have seen Joomla/Controllers/Plugins/Router.php file. This is the most important file. The purpose of the php script in this file is to route request to appropriate controller based on particular action.
James said
As a matter of fact, I did read the entire article. I understand that the function of Router.php is to basically translate the Joomla request and convert that into a ZF controller/action pair. My first question, you can ignore; I think I figured that one out. However, my second question has to do with routing inside the Joomla ZF-based component (in your example com_advertisers). If the component was written originally as a stand-alone ZF-based application, all the routing inside that app will be based on the ZF paradigm of /controller/action/var/value/var/value… If a user clicks on one of these links (an HTML anchor) inside the component, how will Joomla know how to interpret that?
James said
Let me clarify a bit more … My last question really should be: “If a user clicks on one of these links (an HTML anchor) inside the component, how would the web server know to route that back through Joomla’s front controller?” … unless there’s something inside the ZF-based Joomla component that rewrites its requests into something that the web server would route back through Joomla’s front controller.
ZIED said
It’s very intersting.
How to do this with Modules?
ZIED said
It’s very intersting.
How to do this with Modules?
KhoaPham said
Very Impressive.
Firstable, thanks for your idea.
Just only one question to the author:
“Joomla API + Zend frameword: Do they make the website load slower?”
Thanks and refards,