Sunday, December 26, 2010

Netbeans CodeIgniter Autocomplete Tutorial

Netbeans is really an ideal IDE for any sort of development. I just love to use it. Today we will configure Codeigniter in Netbeans with AUTO COMPLETE  feature, it takes about 2 minutes to configure Netbeans for Codeigniter.

Prerequisites

  • CodeIgniter Framework, you can download it from here.
  • Netbeans with PHP support, you can download it from here.
  • WAMP, you can download it from here.

Lets Roll

First download CodeIgniter form above mentioned link and extract the files, now open netbeans and create a PHP project from it New Project... > PHP > PHP Application name the project, say CI_CONFIG and save the project in www directory of wamp (or your PHP server) so that you can access it like http://localhost/CI_CONFIG/index.php
Now copy the CodeIgniter all files to netbeans Project Window as shown in the image below


Please Note, application folder of CodeIgnitor is outside with system folder (which by default is in the system folder)

Now open your web browser and try to run the project with the URL (which in our case is) http://localhost/CI_CONFIG/index.php, if every thing is OK CodeIgniter will greet you and you should be able to see this:


if you will not see this please check where the problem is and Don't forget to start wamp :)

Now, we will create a Controller in controllers directory which is in application/controllers right click on controllers folder New > PHP Class... and name it to say, mySite, copy the following code in mySite
<php

// auto complete goes here

class Mysite extends Controller {

    function Mysite(){ // Constructor
        parent::Controller();
    }
}
?>
at this point auto complete is not working you test is by typing $this-> , to make it work paste the following code as it is in the place of // auto complete goes here
/**
* @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
* @property Image_Upload $image_upload
* @property Lang_Detect $lang_detect
* @property Address_Model $address_model
* @property Admin_Model $admin_model
* @property Buyer_Model $buyer_model
* @property Email_Model $email_model
* @property Product_Model $product_model
* @property Store_Model $store_model
* @property Tailor_Model $tailor_model
*/
now to test is auto complete is there or not yet we create a new method in Mysite
function sayHello(){
        
        $data['message']="Hey, Netbeans is Cooool";
        $this->load->view("sayHello", $data);

    }
when you are typing this you will see code completion feature and also it show documentation of a particular function or attribute as well, it will be something like this:


also create a view, sayHello.php in application/views and in it simply show the message
<?php

echo "

$message

"; ?>
and open your browser with the link http://localhost/CI_CONFIG/index.php/mySite/sayHello you will see following results


and for model just copy these lines at the start of your model class and it work like charm

/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Config $config
* @property CI_Loader $load
* @property CI_Session $session
* @property Address_Model $address_model
* @property Admin_Model $admin_model
* @property Buyer_Model $buyer_model
* @property Email_Model $email_model
* @property Product_Model $product_model
* @property Store_Model $store_model
* @property Tailor_Model $tailor_model
*/
and that is it... you are good to go :)

References
CodeIgniter auto complete with Netbeans

1 comments:

Teegan Cameron on October 24, 2012 at 10:42 PM said...

CodeIgniter in Netbeans works great, it provides us a full graphical user interface and even it odes not uses command based line programming which is a plus point which eases our work upto some extent.


Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems