Search

Codeigniter and Netbeans

This is a short article for configuring Netbeans for use with Codeigniter. It covers configuring the debugger and code completion.

These steps work for Netbeans 7.0 and Codeigniter 2.0.3. I suspect that they work fine with earlier version of both programs but have not been thoroughly tested.

I'm using XAMPP on Windows. These instructions may not apply to other AMP stacks
or operating systems.

The procedure below is not my creation it has been pieced together taken from various web sources
including brettic.us, Tohan, Sturgeon. robsnotebook, leonardteo and various posts on the Codeigniter forum and other forums.


XDEBUG

The first prerequisite is the xdebug program.

Go to http://xdebug.org/. Follow the installation instructions carefully for your OS.


PHP

Modify PHP php.ini to use xdebug.

  • comment out all references to ZEND
  • Add the following section.

[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.1.2-5.3-vc6.dll
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "xdebug_profile.%R::%u"
xdebug.remote_enable = On
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000

If you're unsure what any of the above do please consult the xdebug documentation

  • Restart Apache.
  • Now test with a PHP page containiing phpinfo();

  • Check that xdebug is running and that the various settings are now correctly set.

Browser Plug-in

Firefox

Download the Firefox plugin 'Easy Xdebug 1.5'. Make sure it's enabled.

Chrome

Install 'xdebug helper' from the ‘Chrome Store’

  • Simple test with simplest version of CI.
  • download a fresh CI.
  • Make the following changes to application/config of the default version

$config['uri_protocol'] = 'PATH_INFO';
$config['enable_query_strings'] = TRUE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

Check that it works

  • on the welcome page index function add a few lines setting and displaying a variable
  • set a break point on that line - run debug
  • hit the Netbeans debug button -- the application should start.


You should see an indication that xdebug and netbeans are in communication

  • Set Netbeans to NOT stop on the first line ... this keeps things more or less to your code eliminating debugging through the various 'system' folder code (if they start at line 1 … most don’t but it helps a bit).

Alternative Setup We’ve got htaccess set to hide the index.php … so we have to compensate.

$config['permitted_uri_chars'] = "\'; //a-z0-9~%.:_\-";
$config['enable_query_strings'] = TRUE;
$config['uri_protocol'] = "AUTO";
$config['index_page'] = "index.php/";
$config['css'] = '../application/css/styles.css';
$config['images'] = '../application/images/';
$config['jss'] = '../application/jss/jquery.js';
$config['log_threshold'] = 0;

To test … put a breakpoint in controller login.php index. Then hit the debug button. You should now get all the debugger buttons activated. If you’ve set a break point the code will be stopped at the appropriate line. It might be possible to eliminate the $config[‘index_page’] by removing the contents of the ‘Index File’ in the project properties (I haven’t tried yet).

CODE COMPLETION

  • In the netbeans add a file with the php extension (any file name will do … I’ve choosen netbeans_ci_code_completion.php
  • Cut and paste the following into this file:

<?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
*/
class CI_Controller {};
/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Config $config
* @property CI_Loader $load
* @property CI_Session $session
*/
class CI_Model {};
?>

You will now have codeigniter code completion.


blog comments powered by Disqus