PhpStorm 2024.3 Help

Joomla!

Use PhpStorm as an IDE for Joomla! development.

Enable Joomla! support in PhpStorm

Option 1: Enable Joomla! support in PhpStorm settings

  1. Open Settings (Ctrl+Alt+S) | PHP | Frameworks.

  2. Extend the Joomla! node, select the Enable Joomla! integration checkbox, and specify the parameters as follows:

    Enable Drupal support in settings

    Joomla! installation path

    Specify the path to the root directory that contains the installed Joomla! core.

    Path to JConfig

    Specify the path to the configuration.php file containing the definition of Joomla's JConfig class.

  3. Click Apply to save the changes.

Option 2: Create a new PhpStorm project from a Joomla! template

You can create a new Joomla! project in PhpStorm from a Joomla! integration template.

PhpStorm creates a stub Joomla! project that contains a PHP class <project name>.php and <project name>.xml manifest file. For more information, refer to www.joomla.org.

  1. Open the New Project dialog by choosing File | New Project in the main menu or clicking Create New Project on the PhpStorm Welcome screen.

  2. In the left-hand pane, select Joomla! integration.

  3. In the right-hand pane, specify the Joomla! support parameters. In the Project type field, select one of the Joomla! project types (component, module or plugin) from the list.

Option 3: Import an existing Joomla! project

When you open (File | Open in the main menu) a Joomla! module, plugin, or extension or the Joomla! core directory in PhpStorm, the IDE recognizes the Joomla!-specific project structure and suggests activating Joomla! support.

Joomla project structure detected

Click Enable Support to open the modal dialog and specify the parameters.

    Install Joomla DocBlock templates

    When PhpStorm recognizes the Joomla! project structure, it suggets installing Joomla DocBlocks standards for PHP files, classes, class properties, and so on.

    Joomla DocBlocks installation notification

    Set up Joomla! code style in a PhpStorm project

    If PhpStorm recognizes the project to be a Joomla! module, plugin, or extension, it automatically suggests applying the pre-configured Joomla! code style for this project.

    Enable Joomla! style formatting

    Change code style settings manually

    You can also set the predefined code style manually on the Code Style: PHP page.

    1. In the Settings dialog (Ctrl+Alt+S) , navigate to Editor | Code Style | PHP.

    2. Click Set from and choose Joomla! from the drop-down list that opens.

    Detect databases in Joomla! projects

    PhpStorm detects databases in projects. Click the Add button in the Database tool window tool window and choose Import Data Sources…. The settings specified in the file configuration.php are detected and used for the new data source connection.

    PhpStorm provides database prefixes support and changes #__ to the prefix that is defined in the $dbprefix field in the configuration.php file.

    Additionally, PhpStorm detects the SQL dialect matching your database type and displays a notification prompting you to either set the detected default dialect automatically or to configure it manually on the SQL Dialects page of the Settings dialog (Ctrl+Alt+S) .

    Default SQL dialect notification

    Check code against the Joomla coding standards

    With PhpStorm, you can use the PHP_CodeSniffer tool, which detects coding standard issues, in combination with Joomla Coding Standards, which provides a set of Joomla-specific standards to PHP_CodeSniffer. This will ensure that your code is clean, consistent, and free of some common errors.

    To get started, install PHP_CodeSniffer using any technique described in Install and configure PHP_CodeSniffer. Probably the easiest way is to install it with Composer.

    Install PHP_CodeSniffer

    1. Inside composer.json, add the squizlabs/php_codesniffer dependency record to the require or require-dev key. To get code completion for the package name and version, press Ctrl+Space.

    2. Do one of the following:

      • Click the Install shortcut link on top of the editor panel.

      • If the Non-installed Composer packages inspection is enabled, PhpStorm will highlight the declared dependencies that are not currently installed. Press Alt+Enter and select whether you want to install a specific dependency or all dependencies at once.

    Next, install Joomla Coding Standards, which will provide Joomla-specific standards to PHP_CodeSniffer.

    Install Joomla Coding Standards

    1. Inside composer.json, add the joomla/coding-standards dependency record to the require or require-dev key. To get code completion for the package name and version, press Ctrl+Space.

    2. Do one of the following:

      • Click the Install shortcut link on top of the editor panel.

      • If the Non-installed Composer packages inspection is enabled, PhpStorm will highlight the declared dependencies that are not currently installed. Press Alt+Enter and select whether you want to install a specific dependency or all dependencies at once.

    The Joomla Coding Standards package will be installed, and the corresponding Joomla standard will be selected for the PHP_CodeSniffer validation inspection automatically. If necessary, you can further customize the inspection on the Editor | Inspections page of the Settings dialog (Ctrl+Alt+S) . For more information, refer to Enable PHP_CodeSniffer as a PhpStorm inspection.

    Last modified: 11 October 2024