I discovered few weeks ago an interesting tool to develop Magento modules with Eclipse PDT or Zend Studio: the Magento Eclpise plugin. I use it personnaly with Zend Studio 8 and it works pretty well, so we are going to see the different feature you can get from this module. With this module you can:
- Find two wizards to help you to extend or create Magento modules
- Code completion for core class or method even when you use Mage::getModel() or Mage::getSingleton() and so on.
Install the plugin
In Zend Studio, click on Help
menu > Install Software
. A new window will open, click « Add
« , set a name like « Magento plugin
» then paste the url of the plugin « http://magento-plugin.googlecode.com/svn/update_site »
into the location field. After to have submitted the changes, you should see in the list the plugin. Select it and follow the wizard by clicking on « Next
After the installation process, you will have in the dialog box of the menu New > Other …, a new directory Magento and you will see the two wizards available to start or extend a module.
For your Magento projects, you will have to enable the plugin features for the code completion. Just show on your project folder in your Navigator or PHP Explorer, the contextual menu. You should see the Magento Plugin menu item and sub-item « Add Magento Nature« . Select it to enable the feature for your project.
The code completion seems to work only for core modules of Magento, not for the modules which are in the community or local folder in app/code/ of your Magento installation.
Wizard to create module
To create a module in an easy way. Nothing better than the wizard of the Magento plugin for Ecipse. It makes your life easier because you can directly generate the basic structure folders and configuration xml files. Maybe some of you, will prefer to get more generated files like controllers, block grid for the backend, a model and its resource to get access to the database, you can use instead Module Creator from Netz98 at this address http://www.magentocommerce.com/magento-connect/modulecreator.html
. The counterpart of this last solution is that it won’t feet all of your needs and you should have to remove some part of the codes or files.
Let’s come back on the Magento plugin for Eclipse. To start the wizard, choose in the menu New > Other …, in the new dialog box, search the folder Magento and choose the wizard « Magento Module« . The wizard will start with the informaion to fill in about the module:
- code pool
After you have clicked on « Finish« , your module will have some predefined folder and files in different place in your project. Here is the skeleton:
- app / code / CODE_POOL / NAMESPACE / MODULE_NAME / Block
- app / code / CODE_POOL / NAMESPACE / MODULE_NAME / controllers
- app / code / CODE_POOL / NAMESPACE / MODULE_NAME / Helper / Data.php which is usefull to help you to translate the string of your module
- app / code / CODE_POOL / NAMESPACE / MODULE_NAME / Model
- app / code / CODE_POOL / NAMESPACE / MODULE_NAME / sql and a sub-folder to set your database script for installation and upgrade
- app / etc / modules / MODULE_NAME.xml which is the file to enable or not your module and define the dependencies
Wizard to extend module
The wizard is very similar to the one of the creation module. The difference is that after to have fill in your module information, you will have an additional step to select the module to overwrite and select the classes to overwrite. I could not see completely the result because there were a bug while finishing the wizard. The module was correctly created but didn’t create neither the overwritten class nor updated the config.xml. An issue has been submitted. I will update this article when it will be resolved.