The Blog

How to use codeigniter with eclipse helios

24 Giu 10

Codeigniter is a great framework. Eclipse is a very nice IDE. Why not using them both when writing our own apps ?

After some googling i found a way to get auto-completion with codeigniter on eclipse.

Requirements:

  1. Xampp : I suggest using xampp lite.
  2. Codeigniter: Obviously
  3. Eclipse Helios for PHP Development : ๐Ÿ™‚

Installing Xampp

I suggest Xampp lite zip version. Once downloaded unzip xampp on c:\ ( or wherever you want ) and you’ll get a folder named xampp.

Then browse that folder and execute xampp-start. Once it is started open xampp-control and make sure that apache and mysql is working.

If xampp won’t work, please look at the xampp forum for it.

Installing CodeIgniter

Go into c:\xampp\htdocs and create a new folder called example.com ย ( or wathever you want ) . Then move the unzipped ย codeigniter folder inside c:\xampp\htdocs\example.com\ .

Now navigate inside the c:\xampp\htdocs\example.com\system folder and move “application” one level above so you’ll have the following situation inside c:\xampp\htdocs\example.com:

Now please open the index.php file with your favourite editor. And look if the application and system folder variables are correct ๐Ÿ™‚

In order to check if everything works good you could open your browser and navigate through http://localhost/example.com/ if you don’t get any error then codeigniter and xampp are working correctly.

Installing Eclipse

Installing eclipse is very easy. Just unzip the archive downloaded in the requirements.

Configuring Eclipse in order to work correctly with codeigniter

Create a new Project : File -> New -> PHP Project

The wizard would open. Write CI_CORE on the Project Name field and be sure to make the changes as shown below:

Note: Look at the directory. We are pointing this project on the Codeigniter system folder.

Now click on the Finish button.

Create a new Project : File -> New -> PHP Project

This time, when the wizard opens, write “example.com” on the Project Name Field. Then in the Contents tab use this path:

c:\xampp\htdocs\example.com\application\

Now we should have 2 projects:

  1. CI_CORE
  2. example.com

Now you can see you’ll get autocompletion for almost all things except for the most used :).

In order to fix this issue open:

  • CI_CORE\\codeigniter\\Base4.php file if you are going to develop under PHP5
  • CI_CORE\\codeigniter\\Base5.php if you’re going to develop under PHP4

Note: Yes open Base4 if you’re using PHP5 ๐Ÿ™‚

If you’re using Base4.php Insert the following code just before the constructor.

[sourcecode language=”php”]
/**
* @var CI_Config
*/
var $config;
/**
* @var CI_DB_active_record
*/
var $db;
/**
* @var CI_Email
*/
var $email;
/**
* @var CI_Form_validation
*/
var $form_validation;
/**
* @var CI_Input
*/
var $input;
/**
* @var CI_Loader
*/
var $load;
/**
* @var CI_Router
*/
var $router;
/**
* @var CI_Session
*/
var $session;
/**
* @var CI_Table
*/
var $table;
/**
* @var CI_Unit_test
*/
var $unit;
/**
* @var CI_URI
*/
var $uri;
/**
* @var CI_Pagination
*/
var $pagination;
[/sourcecode]

Well, Now you’ll get eclipse+codeigniter working with some cool things like auto-completion ๐Ÿ™‚
BB ๐Ÿ™‚

Comments