Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Setting up PhpStorm: Difference between revisions

From MoodleDocs
Line 16: Line 16:
==Code formatting==
==Code formatting==


* Setup coding style to use all rules from [Coding style] in "Preferences / Project Settings / Code Style / PHP".
* Setup coding style to use all rules from [[Coding style]] in "Preferences / Project Settings / Code Style / PHP" - 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 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".

Revision as of 00:20, 19 June 2014

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

Install latest Java JDK 1.7.x from Oracle (Java 1.6 from Apple is not maintained much).

You can hack older PhpStorm 7 to be compatible with Java 1.7 by editing the "PhpStorm.app/Contents/Info.plist" file, set JVMOptions - JVMVersion = 1.7*

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"

Code formatting

  •  Setup coding style to use all rules from Coding style in "Preferences / Project Settings / Code Style / PHP" - 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 right margin to 132 or 180 in "Preferences / Project Settings / Code Style / General".

Moodle code checker

TODO

PHPUnit integration

  1. Install PHPUnit via Composer
  2. 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.
  3. Go to "Run / Edit configurations"
  4. Add PHPUnit configuration by clicking on "+"
  5. Click "Use alternative configuration file" and select your phpunit.xml file
  6. Go to "Run / Run ..." and select your new PHPUnit configuration to run

Database editor

  1. Click on the "Database" tab to see the database window
  2. Click "+" in the top left and add "Database source" for your database
  3. Note: click on the link to download the necessary drivers directly from IDE