Joomla and Zend: creating joomla component in Zend Framework

15 May

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.

Directory structure for joomla component in zend.

Directory structure for joomla component in zend.

“Read full version here”. http://zendgeek.blogspot.com/2009/07/joomla-component-in-zend-framework.html

12 Responses to “Joomla and Zend: creating joomla component in Zend Framework”

  1. gabriel solomon May 15, 2009 at 7:42 am #

    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🙂

  2. Peter May 23, 2009 at 10:04 pm #

    nice

  3. James June 18, 2009 at 8:45 pm #

    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?

  4. Faheem Abbas June 19, 2009 at 12:21 pm #

    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.

  5. James June 19, 2009 at 12:44 pm #

    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?

  6. James June 19, 2009 at 12:56 pm #

    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.

  7. ZIED July 6, 2009 at 4:56 pm #

    It’s very intersting.
    How to do this with Modules?

  8. ZIED July 6, 2009 at 4:56 pm #

    It’s very intersting.
    How to do this with Modules?

  9. KhoaPham October 6, 2009 at 7:08 pm #

    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,

  10. amar kumar bhanu December 3, 2009 at 10:57 am #

    i working with zend framework and joomla both so Please suggest me both class is different so which types of plugin install in joomla that joomla understand zend class if possible then Please give me links.., and any demo pack for help me..

  11. nilesh July 3, 2010 at 1:25 pm #

    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?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?

  12. nilesh July 3, 2010 at 1:26 pm #

    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?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 c

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: