|Building a Joomla component using Eclipse for PHP|
|Written by Ian Elliot|
|Monday, 28 September 2009|
Page 1 of 4
Although there are a lot of good tutorials describing how to create a new component for Joomla it can still be difficult to organise all of the material into a procedure for developing using an IDE and a local test environment such as Eclipse for PHP. So here are some more specific instructions about the whole process with nothing left out (I hope!).
Although there are a lot of good tutorials describing how to create a new component for Joomla it can still be difficult to organise all of the material into a procedure for developing using an IDE and a local test environment such as Eclipse for PHP. So here are some more specific instructions about the whole process with nothing left out (I hope!). If you would like to start with the simplest possible module instead of a component then see A Simple Joomla Module with PHP and Eclipse and the other articles in our growing Joomla section.
Why a component?
Why build a component - after all a module is simpler? Although there are many reasons why a component has more going for it - it can have a backend configuration page for example and is generally more sophisticated than a module. However for many the key difference is that while a module can be placed in any of the locations defined by a template and hence show on every page only a component can be the target of a menu item and essentially be the main feature on a page. The front page for example can host many modules but only one component..
So if you know how to create a component it's easy enough to generalise back down to a module and even up to a plug-in.
The prerequisites for this task are that you have a local but possibly remote or even virtual Joomla test system set up and running. It is important that you can restore the test system after making a mess of it and it is, of course very important that nothing you do to the test system can make a mess of the production site. If this isn't the case make it so before proceeding.
It is also assumed that you have a copy of Eclipse for PHP set up and you have imported your Joomla test site as a project and can happily run and debug PHP pages. Again if this isn't the case solve this problem first.
Our first problem is that a component is automatically installed by Joomla which is great for a user but more of a problem for the developer.
One approach is to simply setup the folder structure within Joomla and register the component in the database - this works and its quite quick to get started. The disadvantage is that when you have finished you still have to create an installable version. So despite having being on the receiving end of much advice about not creating an installer and doing it manually I finally decided that it was better to start building the installation folder structure and an installer package.
So the strategy is:
After this we can use the files in the Joomla project to develop and test the component and as long as we remember to update the equivalent files in the component project, a new installation of the component can be made simply by creating a new zip file.
Notice that this isn't entirely ideal in that we have to remember to update the installation project from the live development version of the project but in practice it has proved the easiest option. I've been able to develop the component easily with all of the features of Eclipse including debugging with the component in the environment that it is designed to run in and in the knowledge that the installation is taken care of. Add to the mix the occasional uninstall and reinstall of the component using the installation code base and you can rest easy that when you have finished the component is ready for distribution with no additional testing needed.
One variation on the scheme is to not bother creating the new Eclipse PHP project - just create the folders and files and the zip - but this would mean that you didn't have the benefit of the PHP editors and other facilities when creating or updating the files outside of the full Joomla project.
|Last Updated ( Wednesday, 03 March 2010 )|