PhpStorm: Setup
Here are some hints and examples, what you can do to setup PhpStorm.
Conventions on this page
If you need to select something from the menu in PhpStorm, menu items are displayed like this: File > Settings > ....
General setup
File > Settings > Languages & Frameworks > PHP
(ctrl + alt + s opens File > Settings)
PHP Language Level
: choose appropriate versionCLI Interpreter
: choose appropriate version
Coding Guidelines
Make sure your IDE is setup properly to comply with the Coding Guidelines for TYPO3 (CGL).
EditorConfig
Please note that there is an .editorconfig file in the TYPO3 core repository. See https://editorconfig.org/ for more information. Use the EditorConfig plugin for PhpStorm.
If you use the .editorconfig
file (which is included in the TYPO3 core), some
standard formatting rules are already setup automatically (e.g. indent with
4 spaces for PHP files).
The rules defined in .editorconfig
are very minimal and
it is suggested to see the TYPO3 Coding Guidelines
for more information and toolchain configuration. Please read
PhpStorm documentation on using PHP CS Fixer
for information on how to use the provided
config.php
within PhpStorm.
For a quick start, you can use the following PhpStorm code style to comply with PSR-12, which is the most recent recommendation at the time of this writing that PhpStorm provides a preset for:
PHP files
Set Predefined Style in PhpStorm: File > Settings > Editor > Code Style > PHP > Set From > Predefined Style
Choose PSR-12.
In order to test this, use Code: Reformat Code
to reformat a PHP file.
More information
You can find more information on the Coding Guidelines section in the Appendix.
Plugins for PhpStorm
Here are some plugins, you might use when developing TYPO3. DynamicReturnTypePlugin and Php Inspections are not TYPO3 specific, but will show possible errors and are strongly recommended when developing for the TYPO3 core.
Hint
None of these plugins are mandatory, check out what might be useful for yourself!
Install plugins in PhpStorm
- Open Settings: File > Settings (ctrl + alt + s)
- Select Plugins
- Start typing name of plugin and select a match
- Click on Install.
Recommended Plugins
- EditorConfig plugin
- DynamicReturnTypePlugin :
With this Plugin, return types for some functions can be configured
dynamically. For example, if you use
General
, the expected return type is determined from the first parameter passed to the function. The configuration file for this plugin is dynamicReturnTypeMeta.jsonUtility:: make Instance - Php Inspections (EA Extended) : Static Code Analysis tool for PHP
- reStructuredText plugin: This will show you errors in your reStructuredText files (file ending .rst) when you are editing the core changelog or are updating the documentation for a system extension.
- PHPUnit Enhancement This helps with code-completion and navigation in combination with unit tests and Prophecy (among other things).
- CSV Editor Allows to easily inspect and edit CSV formatted files in a table (for example used in testing fixture files).
Optional Plugins
- Fluid plugin (sgalinski)
- TypoScript plugin (sgalinski)
- * `Gerrit plugin
- <https://plugins.jetbrains.com/plugin/7272-gerrit>`__
- * `TYPO3 CMS Plugin
- <https://plugins.jetbrains.com/plugin/9496-typo3-cms-plugin>`__
- * `TYPO3 XLIFF Utility
- <https://plugins.jetbrains.com/plugin/8098-typo3-xliff-utility>`__
Setting up PhpStorm for the Testing Framework
Optional
Note
It is recommended to use the script runTests.sh for running tests. Alternatively, if you wish to run the unit tests within PhpStorm, you can set them up this way.
First setup the Testing Framework. Replace <YOUR_WEBROOT> with your path to the web directory. You must use absolute paths for this.
Setup Test Frameworks in PhpStorm: File > Settings > Languages & Frameworks > PHP: Test Frameworks:
(ctrl + alt + s opens File > Settings)
- Use composer autoloader
Path to script
: <YOUR_WEBROOT>/vendor/autoload.php- Test runner: Defaut configuration file: <YOUR_WEBROOT>/Build/phpunit/UnitTests.xml
- Test Runner: Default bootstrap file: <YOUR_WEBROOT>/Build/phpunit/UnitTestsBootstrap.php
If this is setup correctly, it will be possible to run your unit tests from within the IDE.
Other Resources
- Susanne Moog: "PhpStorm—a Short Review" (on typo3.org, 17th April, 2019)