Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web site software available. Best of all, Joomla is an open source solution that is freely available to everyone.
- Enabling Joomla! Integration in an Existing PhpStorm Project
- JHtml::_($argument) and JText::_($argument) support
- Joomla! CodeSniffer (?)
- Debugging and Profiling Joomla! Applications with PhpStorm
Enabling Joomla! Integration in an Existing PhpStorm Project
When you open an existing Joomla! Project in PhpStorm then PhpStorm should detect the fact that you're working on a Joomla! application, and ask you to enable the Joomla! integrations.
When we click on Enable, PhpStorm will ask us to browse to the location that the Joomla! codebase is installed, in my case, it was the root of the project I'm working on. It's also worth clicking on the second prompt that asks you if you want to detect the namespace roots; this saves us having to configure the paths for the project manually. If you don't get prompted by the Joomla! Support prompt, you can enable Joomla! support manually by opening the preference pane, and navigating to Languages & Frameworks then PHP and Joomla! Support.
Once we've enabled the Joomla! support, PhpStorm then asks if we would like to enable the Joomla! code styles and if we would like to enable the Joomla! docblock templates. Joomla! has its own rigorous code style and docblocks, so enabling these is always a good idea; we'll learn more about these later.
Creating a New Joomla Module/Plugin/Extension
To create a new Joomla project, go to File then New Project... and select Joomla! Integration from the left hand options. You'll need to tell PhpStorm where to find your Joomla! installation path, give your project a name and select what type of Joomla! project you're going to create. Here we're creating a new Joomla! module.
PhpStorm will then create the `joomla-module.php` file, and the `joomla-module.xml` file that you need to use this project as a Joomla! module. You'll need to edit the configuration XML file before you can use the module.
Development Environment Configuration
Joomla! Include Paths
With Joomla! support enabled and PhpStorm knowing where your Joomla! install is, then the path to this Joomla! install should be included in your include paths by default. You can check this by selecting External Libraries in the left-hand project browser, and check that you can see joomla library root under PHP. If you don't see this, you'll need to add the path to your Joomla! install to your project manually in the usual way.
Joomla! Coding Standard (Code Style)
PhpStorm ships with a coding standard for Joomla! code style, and you should be asked if you want to enable this when you enable Joomla! support. If you wish to enable the Joomla! code style manually, browse to Editor, Code Style then PHP in the preference pane. There, you can add the pre-defined Joomla! styles by clicking Set From..., and selecting Predefined Style then Joomla!
JHtml::_($argument) and JText::_($argument) support
- All the available methods of JHtml are available in the completion list
- Additional tips for required parameters
- When clicking on the identifying $argument the actual subclass plus method are opened (Ask Andrey to help to reproduce)
The latest versions of PhpStorm come with support for the _ static method of the `\JHtml' class. This is a magic method that allows you to invoke helpers by passing in a string that contains the class name plus the method name, separated by a dot. PhpStorm can parse these strings, and provide you with the usual helpers associated with class and method names in the IDE. For example, here we are using the `form.token` helper, and when we invoke Brief Info over the string (default to CMD/CTRL plus hover over the item) we see the method signature for this helper method:
Cmd+Ctrl and clicking the string takes us straight to the `token` static method of the `JHtmlForm` class just as we would expect.
Not done yet
Data source detection
Database prefix support
Joomla! Doc-blocks standard support
Joomla! CodeSniffer (?)
Debugging and Profiling Joomla! Applications with PhpStorm
Joomla!-based projects can be debugged and profiled without any Joomla!-specific configuration.
Please proceed with standard PhpStorm debugging or profiling workflow. For additional details on debugger and profiler configuration, please check this tutorial or relevant videos on the video tutorials page.