Symfony code style
PhpStorm provides the built-in Symfony2 code style tailored for Symfony development.
In the Settings dialog (CtrlAlt0S) , navigate to Editor | Code Style | PHP.
Click the Set from link in the upper-right corner and select the Symfony2 option from the popup menu.
With PhpStorm, you can use the PHP_CodeSniffer tool, which detects coding standard issues, in combination with Symfony coding standard, which provides a set of Symfony-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.
Inside composer.json, add the
squizlabs/php_codesniffer
dependency record to therequire
orrequire-dev
key. To get code completion for the package name and version, press CtrlSpace.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 AltEnter and select whether you want to install a specific dependency or all dependencies at once.
Next, install Symfony coding standard, which will provide Symfony-specific standards to PHP_CodeSniffer.
Inside composer.json, add the
escapestudios/symfony2-coding-standard
dependency record to therequire
orrequire-dev
key. To get code completion for the package name and version, press CtrlSpace.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 AltEnter and select whether you want to install a specific dependency or all dependencies at once.
The Symfony coding standard package will be installed, and the corresponding Symfony 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 (CtrlAlt0S) . For more information, refer to Enable PHP_CodeSniffer as a PhpStorm inspection.
Thanks for your feedback!