Setting up PhpStorm: Difference between revisions
From MoodleDocs
(Add this page to Dev tools category) |
|||
(12 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[http://www.jetbrains.com/phpstorm/ PhpStorm] is a commercial IDE, it is arguably the best IDE for PHP developers with features such as code completion, code inspection, phpunit support, Behat support, database editor, debugger, etc. | [http://www.jetbrains.com/phpstorm/ PhpStorm] is a commercial IDE, it is arguably the best IDE for PHP developers with features such as code completion, code inspection, phpunit support, Behat support, database editor, debugger, etc. | ||
==Installation== | |||
===OS X=== | |||
Do not install Java manually, download a PhpStorm package with bundled java instead. | |||
==General settings== | ==General settings== | ||
Line 6: | Line 12: | ||
* Strip trailing whitespace from "Modified Lines" in "Preferences / IDE Settings / Editor" | * Strip trailing whitespace from "Modified Lines" in "Preferences / IDE Settings / Editor" | ||
* Show line numbers in "Preferences / IDE Settings / Editor / Appearance" | * Show line numbers in "Preferences / IDE Settings / Editor / Appearance" | ||
==Bug tracker integration== | |||
* Add tracker linking in "Preferences / Version control / Issue Navigation" | |||
* Set Issue ID to "MDL-\d+" and Issue link to "https://tracker.moodle.org/browse/$0" | |||
==Code formatting== | ==Code formatting== | ||
* | * Setup coding style to use all rules from [[Coding style]] in "Preferences / Project Settings / Code Style / PHP" (or simply import from https://github.com/enovation/moodle-utils/blob/master/phpstorm-config/Moodle.xml) - this will allow you to use automatic code formatting and it does nice code formatting on copy/paste. | ||
* Set line separator to Unix in "Preferences / Project Settings / Code Style / General". | * Set line separator to "Unix and OS X (\n)" in "Preferences / Project Settings / Code Style / General". | ||
* Set right margin to 132 or 180 in "Preferences / Project Settings / Code Style / General". | * Set right margin to 132 or 180 in "Preferences / Project Settings / Code Style / General". | ||
==Moodle code checker== | ==Moodle code checker== | ||
Follow the instructions in the [https://github.com/moodlehq/moodle-local_codechecker/blob/master/README.md#ide-integration README] | |||
==PHPUnit integration== | ==PHPUnit integration== | ||
# Install [[PHPUnit]] via Composer | |||
# Tell PHPStorm where is composer - go to "Preferences / PHP / Composer", fill in "Path to PHP executable", "Path to composer.phar", "Path to composer.json" and make sure the option "Add packages as libraries" is enabled. | |||
# Go to "Run / Edit configurations" | |||
# Add PHPUnit configuration by clicking on "+" | |||
# Click "Use alternative configuration file" and select your phpunit.xml file | |||
# Go to "Run / Run ..." and select your new PHPUnit configuration to run | |||
==Database editor== | ==Database editor== | ||
# Click on the "Database" tab to see the database window | |||
# Click "+" in the top left and add "Database source" for your database | |||
# Note: click on the link to download the necessary drivers directly from IDE | |||
[[Category:Developer tools|PhpStorm]] |
Revision as of 16:30, 4 September 2018
PhpStorm is a commercial IDE, it is arguably the best IDE for PHP developers with features such as code completion, code inspection, phpunit support, Behat support, database editor, debugger, etc.
Installation
OS X
Do not install Java manually, download a PhpStorm package with bundled java instead.
General settings
- Disable missing @throws tag warning in "Preferences / Project Settings / Inspections / PHP / PHPDoc"
- Strip trailing whitespace from "Modified Lines" in "Preferences / IDE Settings / Editor"
- Show line numbers in "Preferences / IDE Settings / Editor / Appearance"
Bug tracker integration
- Add tracker linking in "Preferences / Version control / Issue Navigation"
- Set Issue ID to "MDL-\d+" and Issue link to "https://tracker.moodle.org/browse/$0"
Code formatting
- Setup coding style to use all rules from Coding style in "Preferences / Project Settings / Code Style / PHP" (or simply import from https://github.com/enovation/moodle-utils/blob/master/phpstorm-config/Moodle.xml) - this will allow you to use automatic code formatting and it does nice code formatting on copy/paste.
- Set line separator to "Unix and OS X (\n)" in "Preferences / Project Settings / Code Style / General".
- Set right margin to 132 or 180 in "Preferences / Project Settings / Code Style / General".
Moodle code checker
Follow the instructions in the README
PHPUnit integration
- Install PHPUnit via Composer
- Tell PHPStorm where is composer - go to "Preferences / PHP / Composer", fill in "Path to PHP executable", "Path to composer.phar", "Path to composer.json" and make sure the option "Add packages as libraries" is enabled.
- Go to "Run / Edit configurations"
- Add PHPUnit configuration by clicking on "+"
- Click "Use alternative configuration file" and select your phpunit.xml file
- Go to "Run / Run ..." and select your new PHPUnit configuration to run
Database editor
- Click on the "Database" tab to see the database window
- Click "+" in the top left and add "Database source" for your database
- Note: click on the link to download the necessary drivers directly from IDE