Difference between revisions of "Configuring Eclipse IDE for PHP development/Linux"

From Joomla! Documentation

< Configuring Eclipse IDE for PHP development
(Some markup changes.)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{underconstruction}}
 
 
{{RightTOC}}
 
{{RightTOC}}
  
Theses instructions should work fine on any Debian based distribution such as Debian, Ubuntu, LinuxMint, Xubuntu, Kbuntu and others.
+
These instructions should work fine on any Debian-based distribution such as Debian, Ubuntu, Linux Mint, Xubuntu and Kubuntu.
  
 +
== Installation ==
 +
There are several ways to download and install the Eclipse IDE to your Linux box. You can do it automatically from the comfort of your software center or using the Linux terminal with few commands or manually downloading and installing the Eclipse IDE from the Eclipse project website or other alternative download sites.
  
== Download and Installation ==
+
=== Method 1: From a Linux Repository ===
 
+
'''NOTE''' This method is recommended because you will automate the installation process and get automatic security patches and bug fix updates when the software is installed from the repositories.
There is 2 ways to download and install Eclipse IDE in your Linux box, you can do it automatically from the comfort of your software center or the Linux terminal with few commands or manually downloading and installing Eclipse  IDE from the Eclipse project website or other alternative download sites.
 
 
 
 
 
=== Method 1: From a Linux repository ===
 
 
 
'''NOTE:''' This method is the most recommended because you will have the benefits of automate all the installation process and get automatic security patches and bug fixes updates when the software is installed from the repositories.
 
 
 
  
 
==== Option 1: Terminal  ====
 
==== Option 1: Terminal  ====
 
 
*Open your terminal and type
 
*Open your terminal and type
  <tt> sudo apt-get install eclipse </tt>
+
  ''sudo apt-get install eclipse''
*Wait until installation process finish
+
*Wait for the installation process to finish.
*If everything whent fine Eclipse IDE should be available in the software menu
+
*If everything went fine, the Eclipse IDE will be available in the software menu.
  
==== Option 2: Software center  ====
+
==== Option 2: Software Center ====
 +
*Open the software center that comes with your distribution.
 +
*Type in the search box ''Eclipse IDE''.
 +
*Select ''Eclipse IDE'' in the search result list.
 +
*Click on the ''install'' button.
 +
*Wait for the installation process to finish.
 +
*If everything went fine, the Eclipse IDE will be available in the software menu.
  
*Open the software center that comes with your distribution
+
=== Method 2: From a Downloaded Copy  ===
*Type in the search box "Eclipse IDE"
+
'''NOTE''' For manual download and installation, you must have Java runtime previously installed or Eclipse IDE will not run.
*Select "Eclipse IDE" in the search result list
 
*Click on the "install" button
 
*Wait until installation processes finish
 
*If everything whent fine Eclipse IDE should be available in the software menu
 
  
=== Method 2: From a downloaded copy  ===
+
To install Java runtime on your Linux box, open a terminal and type following command and wait until the installation finishes:
  
'''NOTE:''' For manual download and installation you got to have JAVA runtime previously installed or Eclipse IDE will not run
+
''sudo apt-get install sun-java6''
  
To install java runtime on your Linux box open a terminal and type folloging command and wait until the installation finish:
+
You can also install Java from your software center. Just type ''openjdk java 6'' and install the package.
  
<tt>sudo apt-get install sun-java6</tt>
+
To get a copy of Eclipse IDE, follow these steps:
  
You can also install java from your software center just type "openjdk java 6" and install the package.
+
*Go to: [https://www.eclipse.org/downloads/ Eclipse download page].
 +
*Download ''Eclipse Classic'' 32 or 64 bits according to your current OS version.
 +
*Unpack the downloaded file to any location that you want. For example: the Downloads folder or the Desktop folder.
 +
*Open the Eclipse folder an find an executable file called ''eclipse''.
 +
*Do a right click on the file then: ''properties → permissions'' and check ''Allow executing file as a program''.
 +
*To execute the Eclipse IDE, you can do a double click on the executable file or run it from terminal. For example:
 +
<syntaxhighlight>
 +
cd ~/Downloads/eclipse/
 +
eclipse
 +
</syntaxhighlight>
  
To get a copy of Eclipse IDE follow these steps:
+
'''NOTE''' At the [https://www.eclipse.org/downloads/ Eclipse download page] you can see many versions of Eclipse IDE. All of them are basically the same Eclipse with several extensions pre-installed to do specific tasks. By default, Eclipse IDE comes with all the tools needed to develop Java projects but you can install more extensions to develop in other languages. Go to [https://www.eclipse.org/downloads/packages/compare Compare Eclipse Packages] to see a complete list of all the extensions included on each Eclipse Package build. You can try one of these pre-build packages specifically created for PHP development. Some of them are official releases from the Eclipse Website and others are independent projects.
  
*Go to: [http://www.eclipse.org/downloads/ Eclipse download page]
+
*[https://www.eclipse.org/pdt/#download Eclipse PDT (PHP Development Tools)]
*Download "Eclipse Classic" 32 or 64 bits according to your current OS version
 
*Unpack the downloaded file on any location that you want, ex: Downloads folder or Desktop folder
 
*Open the eclipse folder an find an executable file called "eclipse"
 
*Do a right click on the file then -> properties -> permissions and check "Allow executing file as a program"
 
*To execute Eclipse IDE, you can do a double click on the executable file or run it from terminal, ex:
 
<tt>cd ~/Downloads/eclipse/
 
eclipse</tt>
 
 
 
'''NOTE:''' At the [http://www.eclipse.org/downloads/ Eclipse download page] you can see many versions of Eclipse IDE, all of them are basically the same Eclipse with a bunch of extensions pre-installed to do specific task by default Eclipse IDE comes with all the tools needed to develop JAVA projects but you can install more extensions to develop in other languages, click in the link [http://www.eclipse.org/downloads/compare.php Compare Packages] to see a complete char of all the extensions included on each Eclipse Package build, you can try one of these pre-build packages specifically created for PHP development some of them are official releases from the Eclipse website and others are independent projects:
 
 
 
*[http://www.eclipse.org/pdt/downloads/ Eclipse PDT (PHP Development Tools)]
 
 
*[http://www.easyeclipse.org/site/distributions/php.html EasyEclipse for PHP]
 
*[http://www.easyeclipse.org/site/distributions/php.html EasyEclipse for PHP]
 
*[http://www.phpeclipse.com/ PhpEclipse]
 
*[http://www.phpeclipse.com/ PhpEclipse]
Line 60: Line 53:
 
{{chunk:Configuring Eclipse IDE for PHP development - Understanding the interface}}
 
{{chunk:Configuring Eclipse IDE for PHP development - Understanding the interface}}
  
== Understanding the Eclipse IDE folder structure ==
+
== Understanding the Folder Structure ==
 +
When you execute Eclipse for the first time, it will ask you to create a ''workspace''. The workspace is a folder where Eclipse IDE will store two things: all your custom configurations and all or some of your projects.
  
When your execute Eclipse for the first time, it ask you to create a "workspace" the workspace is a folder where Eclipse IDE will save the configurations about your editors, perspectives and views also the workspace folder is normally used locate your project files separated by folders, nonetheless you can place your project files outside the workplace folder if you like.
+
All your projects will be separated into folders inside the workspace folder like this:
 
+
<syntaxhighlight>
The workplace folder name could any valid folder name, but by default Eclipse IDE set the name "workplace" to it, and it tries to locate the folder at your documents folder or your home folder, ex "/home/youruser/workspace"
+
/home/youruser/workspace/project-a
 
+
  /home/youruser/workspace/project-b
When you create new PHP project and you decide to place it inside the workplace folder then it may looks like this:
 
 
 
  /home/youruser/workspace/myphptutorial
 
 
  /home/youruser/workspace/joomla_component
 
  /home/youruser/workspace/joomla_component
  /home/youruser/workspace/test
+
  /home/youruser/workspace/joomla-test-site
 +
</syntaxhighlight>
  
Those 3 folders represent 3 different projects inside the same "workspace" and they will share the same editor and perspective layout configuration for Eclipse IDE.
+
You can have more than one workspace. Each of them will contain its own custom configurations and will not affect the information of other workspaces. For example, you can have a workspace located at ''/home/youruser/java-workspace/'' dedicated to contain Java projects and a separate workspace such as ''/home/youruser/php-workspace/'' dedicated to PHP development.
  
The configurations about the editors and perspective layouts are specifically located at the hidden folder called ".metadata" which is right inside the workspace folder, this means you can move the workplace folder from one computer to another and work in Eclipse from another computer with all your custom configurations and projects just easy.
+
As you can see, your workspace folder could be in any valid folder location. For the purposes of PHP development and our convenience, we can set our workspace folder to the same location where our Web server stores its Web files. For example, ''/home/youruser/lamp/public_html/''. This way the Eclipse IDE and our Web server will use the same location for our Web files.
  
== Configuration ==
+
Is important to note that you have the additional option to place your project files outside the workspace locations if you wish. This way Eclipse gives you an additional flexibility in certain cases. For example, let's say we have a workspace located at ''/home/youruser/workspace/'' which contains several random projects, but our server stores its files in a different location at ''/home/youruser/lamp/public_html/''. Of course we want to put our PHP project there so we can edit the files and serve the pages at the same time. Simply create a folder like this: ''/home/youruser/lamp/public_html/my-joomla-project''. Then create a new PHP project and manually specify the path of your new project.
  
 +
What is the difference of projects that are inside and outside the workspace folder? The only noticeable difference is at the moment of creating new projects, When you create a project inside the workspace, Eclipse IDE will automatically create a folder for that project with the same name as the project itself. On the other hand, if the project is outside the workspace location, you can set a random name for the project and then you have to set the path of the project manually regardless of the destination folder name.
  
=== Installing more extensions ===
+
A final note about the behavior of creating new project is that the Eclipse IDE will not let you link an external project that is actually inside your current workspace location. Also you can manually create any folder inside your Eclipse IDE workspace location but that does not mean Eclipse will recognize such folders as a project at all. When you create the new project from the Eclipse IDE that shares the name of an existing folder that already exists in your workspace, Eclipse will automatically link all its contents to your new project.
  
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:
+
When you create a new workspace, Eclipse will automatically create a hidden folder called ''.metadata''. It will contain all your custom global configurations about the editors, perspectives and views. This configuration will be inherited by any new project by default. If you wish, you can override part of the global configuration with custom configurations values specific for each project.
  
*On Eclipse go to: "Toolbar --> help --> install new software"
+
When you create a new project, Eclipse will create these hidden files and folders inside your new project folder:
*You are now on the "Install" window, click the drop-down list  "Work with" and set it to "--All Available Sites--"
+
<syntaxhighlight>
*In the search box type the following keywords and select all the results in the list below:
+
.project
**subversive
+
.buildpath
**Remote Development Support
+
.settings
**php
+
</syntaxhighlight>
**xml editors
+
These files and folders contain information about your custom project configurations and building information that will let Eclipse show tree views of dependencies and classes among many other things.
**xsl editors
 
**javascript
 
**Remote System Explorer
 
**Eclipse Web Developer Tools
 
**Web Page Editor
 
*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 work with local and remote PHP and Joomla development projects, nonetheless you can experiment and tray all the extensions you like.
+
{{Chunk:Configuring Eclipse IDE for PHP development - Configuration}}
  
 +
[[Category:Development]]
  
=== Configuring the perspectives and views ===
+
== Fine Tuning ==
 
+
=== Increase RAM Usage ===
In this case we need to configure Eclipse for PHP development, so you should add the following perspectives:
+
By default, Eclipse gets some configuration information to limit the amount of RAM. This configuration works fine for most users but if you have 2 gigabytes or more of RAM, consider setting this value to improve Eclipse performance.
 
 
*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 [[Setting_up_your_workstation_for_PHP_development | this]] series of articles, but for now leave it for the future.
 
 
 
=== Configuring the editors ===
 
 
 
These are some of the configuration you can do to your editors to improve the user experience:
 
 
 
==== Display white spaces ====
 
 
 
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 ====
 
 
 
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 ====
 
 
 
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 ====
 
 
 
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 conditionals, 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 ====
 
 
 
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"
 
 
 
== Fine tuning ==
 
 
 
=== Increase RAM memory usage ===
 
 
 
By default Eclipse got some configuration to limit the amount of RAM memory, this configurations works fine for most users but if you 2GB of ram or more you should consider set this values to improve Eclipse IDE performance.
 
  
First you got to locate the "eclipse.ini" file that contains some few Eclipse IDE configurations.
+
First locate the ''eclipse.ini'' file that contains some Eclipse configurations.
  
*If you downloaded Eclipse IDE manually from internet the "eclipse.ini" file is just inside the unpacked folder
+
*If you downloaded Eclipse IDE manually from Internet, the ''eclipse.ini'' file is just inside the unpacked folder.
*If you installed Eclipse via terminal or software center the location of the file is "/etc/eclipse.ini"
+
*If you installed Eclipse via terminal or software center, the location of the file is ''/etc/eclipse.ini''.
*In some Linux versions the file can be found at "/usr/share/eclipse/eclipse.ini"
+
*In some Linux versions, the file can be found at ''/usr/share/eclipse/eclipse.ini''.
  
'''NOTE:''' If you found a config file at "/etc/eclipse.ini" then don't edit the file at "/usr/share/eclipse/eclipse.ini"
+
'''NOTE''' If you found a config file at ''/etc/eclipse.ini'', don't edit the file at ''/usr/share/eclipse/eclipse.ini''.
  
This is the content of the original "eclipse.ini" file
+
This is the content of the original ''eclipse.ini'' file:
  
<tt>
+
<syntaxhighlight>
 
  -startup
 
  -startup
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
Line 226: Line 117:
 
  -Xmx384m
 
  -Xmx384m
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
</tt>
+
</syntaxhighlight>
  
To see the full reference about these parameters visit [http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html]
+
To see the full reference about these parameters, visit [https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html].
  
Change the following values to increase the amount of RAM memory used by Eclipse
+
Change the following values to increase the amount of RAM used by Eclipse.
  
<tt>
+
<syntaxhighlight>
 
  -startup
 
  -startup
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
Line 247: Line 138:
 
  -Xmx512m
 
  -Xmx512m
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
</tt>
+
</syntaxhighlight>
  
If you got a lot of RAM memory you can try with these other configuration
+
If you have a lot of RAM you can try these other configurations.
  
<tt>
+
<syntaxhighlight>
 
  -startup
 
  -startup
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 
  plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
Line 266: Line 157:
 
  -Xmx1024m
 
  -Xmx1024m
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
 
  -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
</tt>
+
</syntaxhighlight>
  
 
[[Category:Development]]
 
[[Category:Development]]
 +
[[Category:IDE (Integrated development environment)]]

Latest revision as of 17:26, 5 July 2023

These instructions should work fine on any Debian-based distribution such as Debian, Ubuntu, Linux Mint, Xubuntu and Kubuntu.

Installation[edit]

There are several ways to download and install the Eclipse IDE to your Linux box. You can do it automatically from the comfort of your software center or using the Linux terminal with few commands or manually downloading and installing the Eclipse IDE from the Eclipse project website or other alternative download sites.

Method 1: From a Linux Repository[edit]

NOTE This method is recommended because you will automate the installation process and get automatic security patches and bug fix updates when the software is installed from the repositories.

Option 1: Terminal[edit]

  • Open your terminal and type
sudo apt-get install eclipse
  • Wait for the installation process to finish.
  • If everything went fine, the Eclipse IDE will be available in the software menu.

Option 2: Software Center[edit]

  • Open the software center that comes with your distribution.
  • Type in the search box Eclipse IDE.
  • Select Eclipse IDE in the search result list.
  • Click on the install button.
  • Wait for the installation process to finish.
  • If everything went fine, the Eclipse IDE will be available in the software menu.

Method 2: From a Downloaded Copy[edit]

NOTE For manual download and installation, you must have Java runtime previously installed or Eclipse IDE will not run.

To install Java runtime on your Linux box, open a terminal and type following command and wait until the installation finishes:

sudo apt-get install sun-java6

You can also install Java from your software center. Just type openjdk java 6 and install the package.

To get a copy of Eclipse IDE, follow these steps:

  • Go to: Eclipse download page.
  • Download Eclipse Classic 32 or 64 bits according to your current OS version.
  • Unpack the downloaded file to any location that you want. For example: the Downloads folder or the Desktop folder.
  • Open the Eclipse folder an find an executable file called eclipse.
  • Do a right click on the file then: properties → permissions and check Allow executing file as a program.
  • To execute the Eclipse IDE, you can do a double click on the executable file or run it from terminal. For example:
cd ~/Downloads/eclipse/
eclipse

NOTE At the Eclipse download page you can see many versions of Eclipse IDE. All of them are basically the same Eclipse with several extensions pre-installed to do specific tasks. By default, Eclipse IDE comes with all the tools needed to develop Java projects but you can install more extensions to develop in other languages. Go to Compare Eclipse Packages to see a complete list of all the extensions included on each Eclipse Package build. You can try one of these pre-build packages specifically created for PHP development. Some of them are official releases from the Eclipse Website and others are independent projects.

Understanding the Interface[edit]

The Eclipse IDE is not just a editor. It is a platform and can be used to do many things. It employs a flexible philosophy to denominate and describe the way it displays and organizes the information. The most relevant parts of Eclipse interface are:

  • The tool bar is at the top of the window just like any other common application.
  • The tool bar with buttons is right under the tool bar. It contains several buttons. Most of them change according the current context, view or perspective. You can drag and drop that some buttons to arrange them as you like.
  • The views are sections that divide the windows content and display different kind of information. You can arrange the views in almost any way. For example, columns, rows, complex combinations of columns and rows and so forth.
  • The perspectives are just an arrangement of views in a certain configuration and normally sharing a relationship among them.

It is important to understand how this perspective philosophy works. For example The PHP perspective is used to edit PHP code so is coherent to display views related to the PHP code edition, views to manage the project files and views to navigate through the code. The following is a typical PHP perspective:

  • Docked at the left with several tabs are the PHP explorer view and the Type Hierarchy explorer view.
  • In the middle is a wide view which is the editor area. There will be as many tabs as there are files you are editing.
  • Docked at the right with several tabs are the Search view and the Outline view. They will assist you in finding a chunk of code or to navigate through the parts, variables and object of your current work file.
  • Docked at the bottom with several tabs are the Problems view, Task view, Console view and Progress view. There you will see unsolved problems like syntax errors, uncompleted TODO tasks and the progress of build or update operations.

On the other hand, the Debug Perspective shares some views with the PHP perspective but has a different arrangement of views and more views related to the code debugging operations such as:

  • Debug view: Display the call stack of the current breakpoint.
  • Servers view: Display a list of the configured servers.
  • Variables view: This view shows a tree that is a complete dump of all the variables and object of the current session at the current breakpoint.
  • Breakpoints view: Displays a list of all the breakpoints set in your project. You can double click on one of the items in that list to jump in that exact line of code.
  • Expressions views: Here you can create expressions on the fly to evaluate them without the need to modify the code.

You can switch among perspectives by selecting them at Tool bar → Window → Open perspective or you can click the perspective buttons located at the far right of the The tool bar with buttons.

If you aren't satisfied with any of these perspective configurations and how their views are arranged, you can create your own perspectives and add as many views as you want and arrange them the way that makes you feel good.

  • Modify the current perspective. (Any one. It doesn't matter.)
  • Add the views you want and remove the others you don't.
  • Arrange the views the way you like and that make you feel comfortable.
  • Go to Tool bar → Window → Save perspective as and set a name for your custom perspective. For example: pimp-My-IDE and save it. You can also overwrite an existing view name.

So far you should be able to play with Eclipse IDE and understand its interface philosophy. If you want to see a video demonstration about Eclipse IDE to get a preview and taste some of its powers, check this out Webinar: Using Eclipse for Joomla! Development.

Understanding the Folder Structure[edit]

When you execute Eclipse for the first time, it will ask you to create a workspace. The workspace is a folder where Eclipse IDE will store two things: all your custom configurations and all or some of your projects.

All your projects will be separated into folders inside the workspace folder like this:

 /home/youruser/workspace/project-a
 /home/youruser/workspace/project-b
 /home/youruser/workspace/joomla_component
 /home/youruser/workspace/joomla-test-site

You can have more than one workspace. Each of them will contain its own custom configurations and will not affect the information of other workspaces. For example, you can have a workspace located at /home/youruser/java-workspace/ dedicated to contain Java projects and a separate workspace such as /home/youruser/php-workspace/ dedicated to PHP development.

As you can see, your workspace folder could be in any valid folder location. For the purposes of PHP development and our convenience, we can set our workspace folder to the same location where our Web server stores its Web files. For example, /home/youruser/lamp/public_html/. This way the Eclipse IDE and our Web server will use the same location for our Web files.

Is important to note that you have the additional option to place your project files outside the workspace locations if you wish. This way Eclipse gives you an additional flexibility in certain cases. For example, let's say we have a workspace located at /home/youruser/workspace/ which contains several random projects, but our server stores its files in a different location at /home/youruser/lamp/public_html/. Of course we want to put our PHP project there so we can edit the files and serve the pages at the same time. Simply create a folder like this: /home/youruser/lamp/public_html/my-joomla-project. Then create a new PHP project and manually specify the path of your new project.

What is the difference of projects that are inside and outside the workspace folder? The only noticeable difference is at the moment of creating new projects, When you create a project inside the workspace, Eclipse IDE will automatically create a folder for that project with the same name as the project itself. On the other hand, if the project is outside the workspace location, you can set a random name for the project and then you have to set the path of the project manually regardless of the destination folder name.

A final note about the behavior of creating new project is that the Eclipse IDE will not let you link an external project that is actually inside your current workspace location. Also you can manually create any folder inside your Eclipse IDE workspace location but that does not mean Eclipse will recognize such folders as a project at all. When you create the new project from the Eclipse IDE that shares the name of an existing folder that already exists in your workspace, Eclipse will automatically link all its contents to your new project.

When you create a new workspace, Eclipse will automatically create a hidden folder called .metadata. It will contain all your custom global configurations about the editors, perspectives and views. This configuration will be inherited by any new project by default. If you wish, you can override part of the global configuration with custom configurations values specific for each project.

When you create a new project, Eclipse will create these hidden files and folders inside your new project folder:

 .project
 .buildpath
 .settings

These files and folders contain information about your custom project configurations and building information that will let Eclipse show tree views of dependencies and classes among many other things.

Configuration[edit]

Installing More Extensions[edit]

For your Eclipse IDE you will need to install more extensions for PHP development and other tools to help you in your project development journey. Follow these steps and instructions:

  • In 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:
    • Go to Web, XML, and Java EE Development and select
      • PHP Development Tools (PDT) SDK Feature
      • JavaScript Development Tools
      • Eclipse Web Developer Tools
    • Go to General Purpose Tools and select
      • Remote System Explorer End-User Runtime
  • Press Next → and follow the installation wizard. Restart Eclipse when prompted.
  • In Eclipse, go to: Toolbar → Help → Install new software.
  • Press the Add button and add this new repository, name it xtext plugin.
https://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. Restart Eclipse when prompted.

Those are all the extensions to install for now. They should be enough to do local and remote PHP development. Nonetheless you can experiment and try all the extensions you want.

Configuring the Perspectives and Views[edit]

In this case we need to configure Eclipse for PHP development. Add the following perspectives:

  • In the Toolbar, go to: Window → Perspective → Open Perspective → Other → Debug
  • In the Toolbar, go to: Window → Perspective → Open Perspective → Other → PHP
  • Switch to the PHP perspective.
  • In the Toolbar, go to: Window → Show View → Other → 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 projects. The configuration of these tools are explained in this series of articles.

Configuring the editors[edit]

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

Display Whitespace[edit]

Some people like to see the whitespace represented in the editor. To do so:

  • In the Toolbar, go to: Window → Preferences → General → Editors → Text Editors
  • Check the Show whitespace characters box.
  • Select the Apply and Close button.

Colors[edit]

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

  • In the Toolbar, go to: Window → Preferences → General → Editors → Text editors → Annotations
    • On the list find JavaScript 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.
  • In the Toolbar, go to: 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.
  • In the Toolbar, go to: Window → Preferences → JavaScript → Editor
    • Find the list Appearance color option.
    • On the list find Matching brackets highlight and set the color value to #0000FF.
  • In the Toolbar, go to: 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.
  • In the Toolbar, go to: Window → Preferences → PHP → Editor → Syntax Coloring
    • Find the list Syntax Element.
    • On the list find Classes and set the color value to #1E90FF.
    • 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 Eclipse to check the grammar of your text, enable this option.

  • In the Toolbar, go to: Window → Preferences → General → Editors → Text Editors → Spelling
    • Find and enable Enable spell checking.

Code Folding[edit]

Code folding is a nice feature of some editors. It allow you to fold the code in certain data structures such as functions, classes, conditionals and iterators. We are going to fold all except PHP classes to be able to check and study PHP files quickly.

  • In the Toolbar, go to: Window → Preferences → General → Editors → Structured Text Editors
    • Select the Appearance tab.
    • Find and enable Enable folding.
  • In the Toolbar, go to: Window → Preferences → JavaScript → Editor → Folding
    • Find and enable Enable folding.
    • Find and enable Comments.
    • Find and enable Header Comments.
    • Find and enable Members.
  • In the Toolbar, go to: 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 remove empty lines, delete unnecessary trailing spaces, format the code and more. To activate these features:

  • In the Toolbar, go to: Window → Preferences → PHP → Editor → Save Actions
    • Find and enable Remove trailing whitespace and also select All lines.
  • In the Toolbar, go to: Window → Preferences → JavaScript → Editor → Save Actions
    • Find and enable Perform the selected actions on save.
    • Find and enable Additional actions.
    • Press the Configure... button.
    • Select the tab Code Organizing.
    • Find and enable Remove trailing whitespace.
    • Find and select All lines.
    • Press OK to continue.
  • When you are done, press Apply and Close to save and close the Preferences window.

Fine Tuning[edit]

Increase RAM Usage[edit]

By default, Eclipse gets some configuration information to limit the amount of RAM. This configuration works fine for most users but if you have 2 gigabytes or more of RAM, consider setting this value to improve Eclipse performance.

First locate the eclipse.ini file that contains some Eclipse configurations.

  • If you downloaded Eclipse IDE manually from Internet, the eclipse.ini file is just inside the unpacked folder.
  • If you installed Eclipse via terminal or software center, the location of the file is /etc/eclipse.ini.
  • In some Linux versions, the file can be found at /usr/share/eclipse/eclipse.ini.

NOTE If you found a config file at /etc/eclipse.ini, don't edit the file at /usr/share/eclipse/eclipse.ini.

This is the content of the original eclipse.ini file:

 -startup
 plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 --launcher.library
 plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.100.dist
 -showsplash
 org.eclipse.platform
 --launcher.XXMaxPermSize
 256m
 --launcher.defaultAction
 openFile
 -vmargs
 -Xms40m
 -Xmx384m
 -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins

To see the full reference about these parameters, visit [1].

Change the following values to increase the amount of RAM used by Eclipse.

 -startup
 plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 --launcher.library
 plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.100.dist
 -showsplash
 org.eclipse.platform
 --launcher.XXMaxPermSize
 512m
 --launcher.defaultAction
 openFile
 -vmargs
 -Xms512m
 -Xmx512m
 -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins

If you have a lot of RAM you can try these other configurations.

 -startup
 plugins/org.eclipse.equinox.launcher_1.2.0.dist.jar
 --launcher.library
 plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.100.dist
 -showsplash
 org.eclipse.platform
 --launcher.XXMaxPermSize
 1024m
 --launcher.defaultAction
 openFile
 -vmargs
 -Xms1024m
 -Xmx1024m
 -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins