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: ....
File: Settings: Languages & Frameworks: PHP
PHP Language Level: choose appropriate version
CLI Interpreter: choose appropriate version
Make sure your IDE is setup properly to comply with the Coding Guidelines for TYPO3 (CGL).
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).
However, the rules defined in
.editorconfig are very minimal, so at
least set up PhpStorm to comply with PSR-1 / PSR-2 for PHP as described next.
File: Settings: Editor: Code Style : PHP : Set From : Predefined Style
Choose PSR-1 / PSR-2
In order to test this, use
Code: Reformat Code to reformat a PHP file.
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.
None of these Plugins are mandatory, check out what might be useful for yourself!
File: Settings: Plugins
- EditorConfig plugin
- DynamicReturnTypePlugin :
With this Plugin, return types for some functions can be configured
dynamically. For example, if you use
GeneralUtility::makeInstance, the expected return type is determined from the first parameter passed to the function. The configuration file for this plugin is dynamicReturnTypeMeta.json
- Php Inspections (EA Extended) : Static Code Analysis tool for PHP
- Fluid plugin (sgalinski)
- TypoScript plugin (sgalinski)
- PhpStorm: Gerrit Plugin
- TYPO3 CMS Plugin
- TYPO3 XLIFF Utility
Setting up PhpStorm for the Testing Framework¶
First setup the Testing Framework. Replace <YOUR_WEBROOT> with your path to the web directory. You must use absolute paths for this.
File: Settings: Languages & Frameworks: PHP: Test Frameworks:
- Use composer autoloader
Path to script: <YOUR_WEBROOT>/vendor/autoload.php
- Test runner: Defaut configuration file: <YOUR_WEBROOT>/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
- Test Runner: Default bootstrap file: <YOUR_WEBROOT>/vendor/typo3/testing-framework/Resource/Core/Build/UnitTestsBootstrap.php
If this is setup correctly, it will be possible to run your unit tests from within the IDE.