DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:intellij_idea

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:intellij_idea [2014-03-14 17:32] – [Configure Idea] Update IntelliJIdea version number & add OSX file location ChrisSdevel:intellij_idea [2022-10-27 19:03] (current) – [Path Mappings] andi
Line 1: Line 1:
 ====== IntelliJ Idea ====== ====== IntelliJ Idea ======
  
-[[https://www.jetbrains.com/idea/|IntelliJ Idea]] and it's smaller sister [[https://www.jetbrains.com/phpstorm/|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.+{{https://www.jetbrains.com/img/logos/logo_intellij_idea.png?nolink&200 }} [[https://www.jetbrains.com/idea/|IntelliJ Idea]] and it's smaller sister [[https://www.jetbrains.com/phpstorm/|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 [[user>andi]]. 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 [[user>andi]].
Line 13: Line 13:
   * HTML Tools   * HTML Tools
   * JavaScript Support   * JavaScript Support
-  * PHP+  * PHP 
   * PHPUnit code coverage   * PHPUnit code coverage
  
-Plugins can be installed via ''File'' -> ''Settings...'' -> ''Plugins'' -> ''Browse repositories...''. Click the checkbox to install a deselected plugin. The plugin manager will ask you to install any needed dependencies.+Plugins can be installed via ''File'' -> ''Settings...'' -> ''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. Note: not all of the plugins above might be available (or needed) in PHPStorm.
Line 26: Line 26:
 {{ :devel:idea-newproject.png?500 |New Project Dialog}} {{ :devel:idea-newproject.png?500 |New Project Dialog}}
  
-===== Configure Idea =====+===== Coding Style =====
  
-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:+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:
  
 <file xml ~/.IntelliJIdea13/config/codestyles/DokuWiki.xml> <file xml ~/.IntelliJIdea13/config/codestyles/DokuWiki.xml>
 <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
 +<!--
 +Shell code to update:
 +
 +wget -O dokuwiki-codestyle.xml \
 + https://www.dokuwiki.org/_export/code/devel:intellij_idea?codeblock=0
 +  
 +-->
 <code_scheme name="DokuWiki"> <code_scheme name="DokuWiki">
   <option name="LINE_SEPARATOR" value="&#10;" />   <option name="LINE_SEPARATOR" value="&#10;" />
 +  <JSCodeStyleSettings>
 +    <option name="ALIGN_OBJECT_PROPERTIES" value="1" />
 +  </JSCodeStyleSettings>
   <PHPCodeStyleSettings>   <PHPCodeStyleSettings>
     <option name="ALIGN_KEY_VALUE_PAIRS" value="true" />     <option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
Line 39: Line 49:
     <option name="ALIGN_PHPDOC_COMMENTS" value="true" />     <option name="ALIGN_PHPDOC_COMMENTS" value="true" />
     <option name="ALIGN_ASSIGNMENTS" value="true" />     <option name="ALIGN_ASSIGNMENTS" value="true" />
-    <option name="CONCAT_SPACES" value="false" /> +    <option name="LOWER_CASE_BOOLEAN_CONST" value="true" /> 
-    <option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" /> +    <option name="LOWER_CASE_NULL_CONST" value="true" />
-    <option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />+
   </PHPCodeStyleSettings>   </PHPCodeStyleSettings>
   <XML>   <XML>
Line 48: Line 57:
   <codeStyleSettings language="JavaScript">   <codeStyleSettings language="JavaScript">
     <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />     <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
 +  </codeStyleSettings>
 +  <codeStyleSettings language="LESS">
 +    <indentOptions>
 +      <option name="INDENT_SIZE" value="4" />
 +    </indentOptions>
   </codeStyleSettings>   </codeStyleSettings>
   <codeStyleSettings language="PHP">   <codeStyleSettings language="PHP">
Line 57: Line 71:
     <option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />     <option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
     <option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />     <option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
 +    <option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
     <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />     <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
     <option name="SPACE_AFTER_TYPE_CAST" value="true" />     <option name="SPACE_AFTER_TYPE_CAST" value="true" />
Line 78: Line 93:
 </file> </file>
  
-Then go to ''File'' -''Settings...'' -''Code Style'' and select ''DokuWiki'' from the drop down.+Command to download from this wiki (relative to ''IntelliJIdea/config'' dir): 
 +<code> 
 +wget https://www.dokuwiki.org/_export/code/devel:intellij_idea?codeblock=0 \ 
 +  -O codestyles/dokuwiki-codestyle.xml 
 +</code>
  
-Idea comes with some sensible defaults alreadyThe following are the settings we recommend to change from the default to match with our Go to  for the configuration.+Then go to ''File'' -> ''Settings...'' -> ''Editor'' -> ''Code 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 ''File'' -> ''Settings...'' -> ''Inspections'':+Additionally you may want to configure the following inspections at ''File'' -> ''Settings...'' -> ''Editor'' -> ''Inspections'':
  
   * PHP   * PHP
Line 90: Line 109:
       * Missing PHPDoc comment: true       * Missing PHPDoc comment: true
   * Spelling: false   * Spelling: false
 +
 +===== Path Mappings =====
 +
 +IDEA can make more intelligent suggestions when it knows where which parts are located where. To do so you should add some directory markings.
 +
 +{{ :devel:ideadirectories.png?300|Pathmapping Example}}
 +
 +
 +  * focus the directory tree and press F4
 +  * this should open the Module Settings dialog
 +  * select a directory, then click on the appropriate "Mark as" button at the top
 +  * click the pen icon on the right to configure an associated namespace
 +
 +^ Directory ^ Mark as ^ Namespace ^
 +| ''_test/tests'' | Tests | ''dokuwiki\test'' |
 +| ''inc'' | Sources | ''dokuwiki'' |
 +| ''_test/mock'' | Sources | ''dokuwiki\test\mock'' |
 +| ''data'' | Excluded | |
 +| ''vendor'' | Excluded | |
 +
 +
 +
 +
 +===== Mapping of (plugin) git repositories =====
 +
 +IDEA will automatically keep track of git changes for the main DokuWiki checkout. But usually plugins and templates will have their own .git directory. Telling IDEA about it is a good idea.
 +
 +  - Click on File -> Settings...
 +  - Select "Version Control"
 +  - Select "Directory Mappings"
 +  - At the bottom of the list recognized git repositories are listed. Select to add.
 +
 +
 ===== Integrate Unit Tests ===== ===== Integrate Unit Tests =====
  
 Our [[devel:unittesting|unit tests]] can be integrated directly into Idea. To do so go to ''Run'' -> ''Edit Configurations...''. Our [[devel:unittesting|unit tests]] can be integrated directly into Idea. To do so go to ''Run'' -> ''Edit Configurations...''.
  
-Click the //Add// button and choose ''PHPUnit''. Then fill in these values:+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''   * Name: ''All Tests''
Line 120: Line 176:
  
 ====Individual/plugin test cases==== ====Individual/plugin test cases====
-In order to run individual test cases you need to add a few more settings. Go to ''File'' -> ''Settings...'' -> ''PHP'' -> ''PHPUnit'', here you need to enable ''Use 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 As'' -> ''Test 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.+In order to run individual test cases you need to add a few more settings. Go to ''File'' -> ''Settings...'' -> ''Languages & Frameworks'' -> ''PHP'' -> ''Test 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 As'' -> ''Test 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 ==== ==== 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: To use all the favor of Idea you have to add the PHPUnit source to your project. To add this you have to:
Line 130: Line 190:
   - Select "Libraries" tab   - Select "Libraries" tab
   - Click on the "+" -> Java   - Click on the "+" -> Java
-  - Select your PHPUnit folder (eg. ''/usr/share/pear/PHPUnit''+  - Select your PHPUnit folder (eg. ''/usr/share/pear/PHPUnit'', ''/usr/share/php/PHPUnit'', etc
-  - In the following dialog choose "source"+  - In the following dialog choose "Sources"
   - Click "Ok"   - Click "Ok"
   - Click "Ok"   - Click "Ok"
-  - And your done+  - And you're done
  
 Idea will now index the PHPUnit source and can provide auto completion inside of unit tests. Idea will now index the PHPUnit source and can provide auto completion inside of unit tests.
 +
 ===== Tips and Tricks ===== ===== Tips and Tricks =====
  
devel/intellij_idea.1394814769.txt.gz · Last modified: 2014-03-14 17:32 by ChrisS

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki