CodeIgniter is my favorite web application framework for PHP and Netbeans is the IDE I use for all sorts of web development. The latest version of Netbeans IDE (6.9) has support for both Symfony and Zend Framework. But it still has no official support for CodeIgniter. So, in the default installation, you will always miss the fantastic code completion feature of the IDE.
After Googling a while, I just learned a magic trick that can emulate this feature in Netbeans. The process is pretty simple. We feed Netbeans a php file that has a simple sample “Controller” class definition that has phpdoc specifying the necessary properties. We put this file in a place readable by the IDE but invisible or worthless for the CodeIgniter framework. The “nbproject” directory inside the project root could be a good place to put this file. What really happens is that Netbeans reads the phpdoc and offers the completion of the specified properties in any class that extends the Controller class. Hiding it from CodeIgniter helps not to mess up with the system.
This is what I did. I created a php file and named it “nb.php”. I filled this file with the following contents:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php /** * @property CI_Loader $load * @property CI_Form_validation $form_validation * @property CI_Input $input * @property CI_Email $email * @property CI_DB_active_record $db * @property CI_DB_forge $dbforge * @property CI_Table $table * @property CI_Session $session * @property CI_FTP $ftp * .... */ Class Controller { } ?> |
And put the file inside my nbproject directory. Now I am getting code completion in my Netbeans for CodeIgniter.