Eclipse PDT - Master your dev

Tags : eclipse , php
Maxime THOMAS on 18 of Sep 2011 - 06pm

Manage projects

Eclipse PDT is one of the most powerfull IDE for PHP developpers, even if some prefer to use more classical editors (vim).

When developping your extensions or websites, you might want to have access to all the API of eZ publish, Drupal or other libraries.

To do so, we used to create separate PHP project with the different sources. Let say we want to develop an eZPublish extension. We create the following projects :

  • One for your project, synchronized with a control version system (CVS, SVN, Git...).
  • Another one for your references, eZ publish.

Now, in your project, right click on the project, choose Include Path > Configure Include Path.

Then go in the Projects tab, click on Add, select the project with your eZ publish bundle. You will have something like that :

PDT - Include Path

PDT - Include Path

Click OK to save.

 

If you got some troubles, don't forget that you may not have the last version of PDT (even if downloaded from the website).

You can check updates by Help > Check for updates.

 

Cool shortcuts

Now, some shortcuts to go faster in your development tasks :

  • CTRL + SHIFT + R : Open a resource, open quickly a file if you know its name.
  • CTRL + SHIFT + T : Open a type, open quickly a class if you know its name.
  • CTRL + SHITF + H : Open a type in hierarchy, quickly open the hierarchy of a class if you know its name.
  • F3 :
    • On a class name, open the class file.
    • On a function name, open the function inside the class file.

And autocomplete feature on words, for example, in a PHP file, do CTRL + SPACE :

  • On a class name, will give you purposes for the class name. Example : type eZU and you will get eZUser, eZUserAccount...
  • On a variable, if Eclipse succeeds in determining the type, it will find the class and the functions for you. Example : typing $node->fet will return all the functions for eZContentObjectTreeNode class.

Cooler shortcuts

You can use CTRL and ALT with arrows, tab and Page Down and Page up.

  • CTRL + UP or DOWN : make scroll the file without moving the cursor.
  • CTRL + PAGE DOWN or PAGE UP : go to the following or previous open file (works also in Firefox with tabs, in Excel with Sheets...)
  • ALT  + UP or DOWN : swap lines, useful to move one line or one block from one place to another without using cut and paste
  • CTRL + ALT + UP or DOWN : copy the selection just after or just before, useful to duplicate lines.
  • CTRL + TAB : useful to change from one tab to the next one.
  • CRTL + K : on a selection, will find the exact same instance.