Chunk

Configuring Eclipse IDE for PHP development - Configuration

From Joomla! Documentation

Configuration[edit]

Installing more extensions[edit]

For your Eclipse IDE you will need to install more extension for PHP development and other tools to help you in your project development journey, follow this steps and indications:

  • On Eclipse go to: "Toolbar --> help --> install new software"
  • You are now on the "Install" window, click the drop-down list "Work with" and set it to "--All Available Sites--"
  • In the list expand the nodes and find the following packages to install:

Note: You can also use the search box, but for some reason (maybe a bug) Eclipse IDE hangs for few seconds on every search.

    • goto "Web, XML, and Java EE Development" and select
      • PHP Development Tools (PDT) SDK Feature
      • JavaScript Development Tools
      • Eclipse Web Developer Tools
    • goto "General Purpose Tools" and select
      • Remote System Explorer End-User Runtime
  • Press "Next>" and follow the installation wizard and restart Eclipse if needed
  • On Eclipse go to: "Toolbar --> help --> install new software"
  • Press the "Add" button and add this new repository, name it "xtext plugin"
http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
  • Press the "Add" button and add this new repository, name it "LESS plugin"
http://www.normalesup.org/~simonet/soft/ow/update/
  • Press "Ok" and wait until eclipse fetches all the new elements
  • In the selection box next to the "Add" button select the "LESS plugin ..." repository
  • On the list below find the "LESS" option and check it
  • Press "Next>" and follow the installation wizard and restart Eclipse if needed

Those are all the extension to install for now, they should be enough to do local and remote PHP development, nonetheless you can experiment and tray all the extensions you want.

Configuring the perspectives and views[edit]

In this case we need to configure Eclipse for PHP development, so you should add the following perspectives:

  • Go to: "Toolbar --> windows --> open perspective --> others --> debug"
  • Go to: "Toolbar --> windows --> open perspective --> others --> php"
  • Switch to the "PHP perspective"
  • Go to: "Toolbar --> windows --> show view --> others --> remote systems"
  • Drag the view from the tab and drop it next to the "PHP explorer" view

Now you can explore local and remote PHP project, how to configure this tools will be explained in this series of articles, but for now leave it for the future.

Configuring the editors[edit]

These are some of the configuration you can do to your editors to improve the user experience:

Display white spaces[edit]

Some people like to see the white spaces represented in the editor to do so:

  • Go to "Toolbar --> window --> preferences --> general --> editors --> text editors"
  • Set "show whitespace characters" to check

Colors[edit]

To highlight some the parts of the code with stronger colors, follow this steps:

  • Go to "Toolbar --> window --> preferences --> general --> editors --> text editors --> annotations "
    • On the list find "java scrip occurrences" and set the color value to "#FFFF5A"
    • On the list find "matching tags" and set the color value to "#FFFF5A"
    • On the list find "php elements read occurrences" and set the color value to "#FFFF5A"
  • Go to "Toolbar --> window --> preferences --> general --> editors --> structured text editor"
    • Find the list "Appearance color options"
    • On the list find "Matching brackets highlight" and set the color value to "#0000FF"
  • Go to "Toolbar --> window --> preferences --> javascript --> editor"
    • Find the list "Appearance color options"
    • On the list find "Matching brackets highlight" and set the color value to "#0000FF"
  • Go to "Toolbar --> window --> preferences --> javascript --> editor --> syntax coloring"
    • Find the list "Element"
    • On the list find "javascript --> functions" enable the option and set the color value to "#1E90FF"
    • On the list find "javascript --> function declarations" enable the option and set the color value to "#1E90FF"
    • On the list find "javascript --> local variable declaration" enable the option and set the color value to "#A52A2A"
    • On the list find "javascript --> local variable references" enable the option and set the color value to "#A52A2A"
    • On the list find "javascript --> parameter variables" enable the option and set the color value to "#A52A2A"
  • Go to "Toolbar --> window --> preferences --> php --> editor --> syntax coloring"
    • Find the list "Syntax element"
    • On the list find "functions" and set the color value to "#1E90FF"
    • On the list find "methods" and set the color value to "#1E90FF"
    • On the list find "variable" and set the color value to "#A52A2A"

Spell checking[edit]

If you want that eclipse assist you on check the grammar of your text, enable this option.

  • Go to "Toolbar --> window --> preferences --> general --> editors --> spelling"
    • Find and enable "enable spell checking

Code folding[edit]

Code folding is a nice feature of some editor, it allow you to fold the code in certain data structures like functions, classes and other structures such as classes, conditionals and iterators, we are going to fold all the possible except classes content to be able to check and study PHP files quickly

  • Go to "Toolbar --> window --> preferences --> general --> editors --> structured text editors"
    • Clink on the tab "appearance"
    • Find and enable "enable folding"
  • Go to "Toolbar --> window --> preferences --> javascript --> editor --> folding"
    • Find and enable "enable folding"
    • Find and enable "comments"
    • Find and enable "header comments"
    • Find and enable "members"
  • Go to "Toolbar --> window --> preferences --> php --> editor --> code folding"
    • Find and enable "enable folding"
    • Find and enable "functions"
    • Find and enable "phpdoc"
    • Find and enable "header phpdoc"

code cleaning[edit]

Eclipse provides some nice utilities to automatically clean the source code of some extra garbage such as cleaning empty lines, deleting unnecessary trials spaces, formatting to the code and more. To activate some of this features follow these instructions:

  • Go to "Toolbar --> window --> preferences --> javascript --> editor --> content assist --> save actions"
    • Find and enable "Additional actions"
    • Press the button "Configure"
    • Find the tab "code organizing"
    • Find and enable "remove trailing whitespaces" and also select "all lines"
    • Press the button "ok"
  • Go to "Toolbar --> window --> preferences --> php --> editor --> save actions"
    • Find and enable "Remove trailing whitespaces" and also select "all lines"
  • Go to "Toolbar --> window --> preferences --> javascript --> editor --> save actions"
    • Find and enable "Perform the selected actions on save"
    • Find and enable "Additional actions"
    • Press the button "Configure..."
    • Select the tab "Code organizing"
    • Find and enable "Remove trailing whitespaces"
    • Find and select "All lines"
    • Press "ok" to close exit