CodeIgniter: Autocomplete in NetBeans IDE

Developing a project on CodeIgniter, with so many libraries and  helpers  that the framework offers and with so many other classes of its own and / or third parties without the autocomplete  feature  that current editors and IDEs offer is insanity. It is very difficult to know / remember all the methods of a given class, what they receive as a parameter and what they return.

I develop my projects on NetBeans , and although it provides a huge range of code autocomplete  suggestions  for PHP’s native functions and even some frameworks, for CI we have to configure this feature manually.So, I will share with you in this post, how to make your NetBeans recognize the CodeIgniter classes and give you code autocomplete  suggestions  naturally when you are programming or when you press CTRL + Space .

For it to work, obviously, your project must be created in the IDE and the framework files included. In order for NetBeans to be able to map CI classes, you must inform them through  annotations  within a file (you could do this file by file only for those classes that are used, but here we will generalize).

I particularly place this file with the  annotations  in a subdirectory of the nbproject  folder  (since this folder is generally not versioned or placed in a production environment).

Well, then inside the nbproject  folder  I will create the CI_Autocompletes  folder  and in it a new file called CI_Autocompletes.php

Within this file, I will put the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php 
/ **
 * @property CI_DB_active_record $db
 * @property CI_DB_forge $dbforge
 * @property CI_Benchmark $benchmark
 * @property CI_Calendar $calendar
 * @property CI_Cart $cart
 * @property CI_Config $config
 * @property CI_Controller $controller
 * @property CI_Email $email
 * @property CI_Encrypt $encrypt
 * @property CI_Exceptions $exceptions
 * @property CI_Form_validation $form_validation
 * @property CI_Ftp $ftp
 * @property CI_Hooks $hooks
 * @property CI_Image_lib $image_lib
 * @property CI_Input $input
 * @property CI_Language $language
 * @property CI_Loader $load
 * @property CI_Log $log
 * @property CI_Model $model
 * @property CI_Output $output
 * @property CI_Pagination $pagination
 * @property CI_Parser $parser
 * @property CI_Profiler $profiler
 * @property CI_Router $router
 * @property CI_Session $session
 * @property CI_Sha1 $sha1
 * @property CI_Table $table
 * @property CI_Trackback $trackback
 * @property CI_Typography $typography
 * @property CI_Unit_test $unit_test
 * @property CI_Upload $upload
 * @property CI_URI $uri
 * @property CI_User_agent $user_agent
 * @property CI_Validation $validation
 * @property CI_Xmlrpc $xmlrpc
 * @property CI_Xmlrpcs $xmlrpcs
 * @property CI_Zip $zip
 * 
 * Add addtional libraries you wish
 * to use in your controllers here
 * 
 * / 
class CI_Controller { } ; 
/ **
 * @property CI_DB_query_builder $db
 * @property CI_DB_forge $dbforge
 * @property CI_Config $config
 * @property CI_Loader $load
 * @property CI_Session $session
 *
 * Add addtional libraries you wish
 * to use in your models here.
 * 
 * / 
class CI_Model { } ; 
?>

And ready! Do the test. Go to a Controller or Model, load some Lib and see the result. CI classes will be in the NetBeans suggestions the moment you are implementing them.

I hope this tip is useful to you.

Any questions post a comment.

Hugs!!!

Holds a university degree in Information Systems, a postgraduate degree in Database Systems and a master's degree in Education with a focus on Sociocommunity Technologies. He works as a professor of technical and technological education at the Federal Institute of Education, Science and Technology of São Paulo, teaching subjects in the areas of programming, database, project development and software engineering.

Posts relacionados

Comentários

Leave a Reply

Your email address will not be published. Required fields are marked *