While I prefer to make quick changes to my code in a lightweight text editor, any lengthy coding session usually involves loading up an IDE in order to have access to all of the extra time-saving features. Code completion is one of those hard-to-live-without features that IDEs provide.. here’s a quick rundown showing how to get it working with any library or class (visible to your buildpath) to work under Eclipse + PDT.
The idea is very simple, although it is a bit of a trick as you have to apply it to any/every project you work on. Using PHPDoc’s @property you can reference any variable in a class (even if it hasn’t been declared) and associate it with a PHP Type. PDT does the rest!
For example, this is how you can add code completion to a CodeIgniter project’s controller classes:
Create a custom base controller (ie. MY_Controller — see the CI guide for more info) and at the top, in the class’ PHPDoc, add @property tags for any variable you want to use. Now any controllers you create, that extend MY_Controller, will automatically have code completion enabled for the variables you tag. In the following example, $load, $session and $output will be available.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * Base Controller Class * @property CI_Loader $load * @property CI_Session $session * @property CI_Output $output */ abstract class MY_Controller extends CI_Controller { // ... } |
Well this was informative, I will keep this site for more later.
hiii.. i’ve posted same topic with this.. but use some other way. hope we can share each other. thank you, nice info.. http://sl33py.web.id/2013/01/27/codeigniter-code-completion-on-eclipse-pdt/