This tutorial describes the features and best practices relevant to in using PhpStorm as an IDE for Joomla development. Starting with version 2016.1.1, PhpStorm bundles the Joomla! Plugin providing many Joomla!-specific features.
Joomla is is an award-winning content management system (CMS), which enables you to build Web sites websites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web site website 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
When you we open an existing Joomla! Project in PhpStorm then , PhpStorm should detect the fact that youwe're working on a Joomla! application , and ask you us to enable the Joomla! integrations.
When we click on Enable, PhpStorm will ask us to browse to the location that where the Joomla! codebase is installed, in . In my case, it was is 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.
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 (unless you've already specified it at the previous step), 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.
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 Settings | PHP | Include path .
Joomla! Coding Standard (Code Style)
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 over the string (default to CMD/CTRL plus hover over the item), we see the method signature for this helper method:
Holding CMD/CTRL and clicking the string takes us straight to the `token` static method of the `JHtmlForm` class just as we would expect. Of course, the `JHtml` class comes with full code completion and type hinting like all classes do in PhpStorm.
Similarly to the JHtml support, PhpStorm now also supports the static methods of the `JText` class. Text allows you to handle translations from definitions (typically in .ini files) and output the translation in the correct place. When you use the `_` or `sprintf` or 'script' methods of `JText` and pass in a valid string with a key name, PhpStorm will allow you to use Brief Info and navigate to the definition (using CMD/CTRL and click) to be taking taken directly to the .ini file that defined that key.
Data source detection
We then see the Add New Datasource dialog, but with all the fields completed from the settings in the `configuration.php` file; it's simply a case of hitting . Simply click Test Connections to check everything is working, and then hitting click OK.
Database prefix support
PhpStorm provides database prefixes support and changes #__ on fly to the prefix that is defined in the $dbprefix field in the configuration.php file (. You will also have completion working for your SQL queries.To have it working, make sure that SQL Dialect for project is equal to Database (Settings-> SQL Dialects).
If you Ctrl+Click, you can navigate directly to the table from the query.
Joomla! Doc-blocks standard support
Joomla! code styles have strict standards about docblocks - including which docblock annotations are required, and which are optional, and which order they should be presented in. PhpStorm now ships with an inspection the that will tell you exactly what is wrong with your docblocks, and why they don't meet Joomla! strict standards.
Joomla! provides a ruleset for use with PHP CodeSniffer, and PhpStorm comes with support for PHP CodeSniffer out - of - the - box.
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 .