It's better when it's simple

User Tools

Site Tools


Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community

Follow us on Facebook, Twitter and other social networks.

Our Privacy Policy


IntelliJ Idea

IntelliJ Idea and it's smaller sister PHPStorm are commercial IDEs with excellent PHP coding support. Idea has support for a wide range of programming languages, while PHPStorm is aimed at PHP only.

The DokuWiki project has been provided with a free, unlimited user license for Idea by JetBrains. Regular DokuWiki contributors can apply for the free license key by sending a simple mail to andi.

Setup Idea Plugins

After installing, you should make sure you have at least the following plugins enabled:

  • CSS Support
  • Git Integration
  • HTML Tools
  • JavaScript Support
  • PHP
  • PHPUnit code coverage

Plugins can be installed via FileSettings…Plugins. Some are already installed, see “Installed”. The missing plugins can be found via Marketplace. The plugin manager will ask you to install any needed dependencies.

Note: not all of the plugins above might be available (or needed) in PHPStorm.

Create an Idea Project for DokuWiki

Do a git checkout of DokuWiki. Then start Idea and select FileNew Project…. In the next dialog select Create project from scratch. In the final dialog, browse to your checkout and select “Web Module”. Click finish and you're done.

New Project Dialog

Configure Idea

To setup Idea for DokuWiki's coding style, download the following file and place it into your .IntelliJIdea13/config/codestyles(Win/*nix) ~/Library/Preferences/IntelliJIdea13/codestyles(OSX) folder:

<?xml version="1.0" encoding="UTF-8"?>
Shell code to update:
wget -O dokuwiki-codestyle.xml \
<code_scheme name="DokuWiki">
  <option name="LINE_SEPARATOR" value="&#10;" />
    <option name="ALIGN_OBJECT_PROPERTIES" value="1" />
    <option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
    <option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
    <option name="ALIGN_PHPDOC_COMMENTS" value="true" />
    <option name="ALIGN_ASSIGNMENTS" value="true" />
    <option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
    <option name="LOWER_CASE_NULL_CONST" value="true" />
    <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
  <codeStyleSettings language="JavaScript">
    <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
  <codeStyleSettings language="LESS">
      <option name="INDENT_SIZE" value="4" />
  <codeStyleSettings language="PHP">
    <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
    <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
    <option name="CLASS_BRACE_STYLE" value="1" />
    <option name="METHOD_BRACE_STYLE" value="1" />
    <option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
    <option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
    <option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
    <option name="SPACE_AFTER_TYPE_CAST" value="true" />
    <option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
    <option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
    <option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
    <option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
    <option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
    <option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
  <codeStyleSettings language="SCSS">
      <option name="INDENT_SIZE" value="4" />
      <option name="CONTINUATION_INDENT_SIZE" value="4" />

Command to download from this wiki (relative to IntelliJIdea/config dir):

wget \
  -O codestyles/dokuwiki-codestyle.xml

Then go to FileSettings…EditorCode Style and select DokuWiki from the drop down. (Maybe you have to restart first before scheme is shown)

Additionally you may want to configure the following inspections at FileSettings…EditorInspections:

  • PHP
    • General
      • Unresolved include : false (Idea isn't able to resolve our includes even though they are completely correct)
    • PHPDoc
      • Missing PHPDoc comment: true
  • Spelling: false

Integrate Unit Tests

Our unit tests can be integrated directly into Idea. To do so go to RunEdit Configurations….

First set default configuration, then you don't have to do that in next steps

Under Templates find PHPUnit and check Use alternative configuration file, fill <path to>/_test/phpunit.xml, leave everything as is and press Apply.

Click the + button (i.e. top left button with on hover 'Add New Configuration') and choose PHPUnit. Then fill in these values:

  • Name: All Tests
  • Test Runner
    • Test Scope: Defined in the configuration file
    • Use alternative configuration file: <path to>/_test/phpunit.xml
  • Command Line
    • Interpreter options: -d output_buffering=On

Repeat to add another config with these values:

  • Name: Fast Tests
  • Test Runner
    • Test Scope: Defined in the configuration file
    • Use alternative configuration file: <path to>/_test/phpunit.xml
    • Test Runner options: --exclude-group slow,internet
  • Command Line
    • Interpreter options: -d output_buffering=On

Run Configuration

You now can run all or only the fast tests directly from the Run menu or the dropdown in the toolbar.

Note: the -d output_buffering=On option is needed until this bug is fixed.

Individual/plugin test cases

In order to run individual test cases you need to add a few more settings. Go to FileSettings…Languages & FrameworksPHPTest Frameworks, Use + button to add a configuration. Here you need to enable Default configuration file and specify the <path to>/_test/phpunit.xml.

Then you need to mark either under Directories in the project settings or directly in the project tree the _test/tests via context menu option Mark directory AsTest Source Root and do the same for any plugin test directories. After that you can run or debug individual test cases by choosing run or debug in the context menu of the file in the project tree.

PHPUnit autocompletion

Note: only needed for older versions of IDEA intellij. Is today automatically retrieve from the phpunit.phar.

To use all the favor of Idea you have to add the PHPUnit source to your project. To add this you have to:

  1. Open your project
  2. Click on File → Project Structure
  3. Select “Libraries” tab
  4. Click on the “+” → Java
  5. Select your PHPUnit folder (eg. /usr/share/pear/PHPUnit, /usr/share/php/PHPUnit, etc)
  6. In the following dialog choose “Sources”
  7. Click “Ok”
  8. Click “Ok”
  9. And you're done

Idea will now index the PHPUnit source and can provide auto completion inside of unit tests.

Tips and Tricks

Press CTRL-ALT-L to reformat the current file according to the code style settings. Be sure to check in such cleanups as separate commits from any logic changes.

If Idea fails to understand the class type of a (global) variable, annotate it with a type hint:

function foo(){
    /* @var Input $INPUT */
    global $INPUT;
    // thanks to the type hint Idea now knows this is valid:
    echo $INPUT->str('foo');

Hit ALT-Enter to “autofix” problems detected by Idea. Works very well to insert missing doc blocks for example.

devel/intellij_idea.txt · Last modified: 2021-02-28 18:20 by Klap-in