Category: PDT for Eclipse

rss

PDT auto completion tips (for agavi)

de en

In PDT (php development tools for eclipse) you are able to do auto completion (e.g. ctrl+space) on most of the classes, as long as they are defined properly or you have a proper php-doc set up. Check that tutorial, if you want to set up PDT.

Graste posted a snippet, which tells eclipse for the project (in this example it's agavi) that the variables (which are common for templates), like $template (or $ro, $rd and so on) are defined with correct type.

Here is a slightly modified autocomplete.php:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
exit();
$slots = array();
$template = array(); // agavi 0.11 default
$t = array(); // agavi 1.0 default
$tm = new AgaviTranslationManager();
$ro = new AgaviWebRouting();
$rq = new AgaviWebRequest();
$ct = new AgaviController();
$us = new AgaviSecurityUser();
$rd = new AgaviWebRequestDataHolder();
?>

Just save that file to autocomplete.php in your project structure -> eclipse will use this classes as default, so you have neat auto completion even in agavi templates.

If you have return type for a function, and want the caller to be able to autocomplete: just use proper php-docs. For example, the following will give SomeClass-typed elements on a function test123:

1
2
3
4
5
6
/**
* @return SomeClass
*/
function test123() {
/* ... */
}

If you just want autocomplete for a specific scope, you may use the following:

1
if (false) $instance = new SomeClass();

or better

1
/* @var $instance SomeClass */

and auto completion on $instance will work like if it was a SomeClass.

Got another tip? Feel free to add it in the comments!

In open source, php, Agavi, Eclipse & PDT for Eclipse By DracoBlue @ 18:54 23.02.2009

How to install and run latest (stable) PHP for Eclipse (PDT)

If you want to run latest stable 2.1 version of PDT (the eclipse extension for PHP) you'll find a all-in-one version at the eclipse pdt download page.

Just scroll down a bit, until you find 2.1.0 Stable Builds and download All-In-One (around 167MB).

Once downloaded the .zip file, copy the contents of that file to a directory.

Windows-Users:
Copy it somewhere with a short path, e.g. c:\eclipse (good!) or c:\apps\eclipse (good!). Do not install it to c:\program files\eclipse (not!) or c:\document and settings\jan\apps\eclipse (not!).

There are two reasons for this:

  • If you are running eclipse on e.g. VISTA or XP with insufficient rights to write the program files folder: it will tend to fail.
  • On Windows there is [x] a 260 characters for a path-name limit, you may exceed it if you put eclipse in a too extra ordinary root folder.

Launch the eclipse(.exe) in that folder.

Eclipse will launch and ask you where to put the workspace to. The workspace will be used as cache and will store configuration files for each of your projects. You are still able to locate the projects outside of your workspace!

If you will have projects accessible only over network shares, put your workspace on your local disk and in new project wizard select the network share. This will minimize load for cache/index.

In open source, php, Eclipse & PDT for Eclipse By DracoBlue @ 11:34 12.02.2009