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

  • jiten

    Wow this is great!

    made 02 projects as suggested in the post.. and then pasted the following code before constructor in base4.php..

    thanks a lot…it is working with eclipse PDT

  • I’m happy to know i helped you out ๐Ÿ™‚

  • webpigๆต่งˆๅ™จๆŽจๅนฟๆผ”็คบ๏ผš้‡‡้›†+็พคๅ‘ใ€่‡ชๅŠจ่ฏ†ๅˆซใ€‘ๆ‰€ๆœ‰ไธปๆต็ฝ‘็ซ™็จ‹ๅบ๏ผŒ่ฟ˜ๅฏไปฅ่‡ชๅทฑๅ†™้‡‡้›†่ง„ๅˆ™๏ผ‰SEOไผ˜ๅŒ–ๆŽจๅนฟ๏ผŒๅšๅฎข็พคๅ‘๏ผŒๅšๅฎข็พคๅปบ๏ผŒๅšๆ–‡็พค่ฏ„๏ผŒๅšไธป้€ ๆ˜Ÿ๏ผŒEmail็พคๅ‘๏ผŒ่ฎบๅ›็พคๅ‘๏ผŒ่ฎบๅ›็Ÿญๆถˆๆฏ็พคๅ‘๏ผŒSEOๅ›žๅคๆต้‡ๅˆท๏ผŒๅคšไบบ้กถ่ดด๏ผŒๅšๅฎข็•™่จ€่ธฉ๏ผŒๆ•ฐๆฎๆŒ–ๆŽ˜๏ผŒๆ‰€ๆœ‰่‰ๆ น็บงๆŽจๅนฟๅทฅๅ…ทใ€‚ๅ…ถไป–็ซ™้•ฟๅŠŸ่ƒฝๆญฃๅœจไธๆ–ญๅผ€ๅ‘๏ผŒๆœ‰้œ€ๆฑ‚่ฏทๆต่งˆๅฎ˜ๆ–น่ฎบๅ› bbs.webpig.org

  • Super site! Your style is so refreshing in comparison to most other bloggers. Thank you for writing when you get the chance to, I’ll be sure to keep visiting!

  • asifsomy

    this really works for me. can i load all methods of model? how??

  • veke87

    Simply write the models on the Base4 following the schema shown above ๐Ÿ˜›

    Everything works fine then..

    I’m currently working to have a better way to accomplish this ๐Ÿ˜›

  • asifsomy

    of course i already did that but didn’t work for me..models methods are not loading..

    Moreover can u tell me how will i run my codeigniter controller in Eclipse PDT?

  • Basically you can’t run a codeigniter project on eclipse you’ve to load a webtab and refresh it ๐Ÿ™‚

    Btw, i found a better way to achieve this task ๐Ÿ™‚

  • What is the “better way” to achieve this task you mentioned in your last reply Andrea?

  • Skip Hop Studio Diaper Tote Bag is awesome.So quite a few pockets – as well as not those little, worthless pockets, either. All of the actual storage compartments tend to be a fantastic size and genuinely help keep every thing organized. The handles are a good length and fit nicely more than the actual shoulder; the tackle shoulder straps also stay put on my own shoulder, which is actually critical as soon as you are carrying a infant. The tote looks great, too. Not as well fancy, but not too casual. (I have it in black) The material is soft (can’t consider of a better word) so it’s easy to squeeze in to tight spaces – but yet it is sturdy. I’ve a Fleurville Lexi carrier and I love it, as well, but this handbag is type of inflexible. I think that Skip*Hop may grow to be my everyday bag. It’s a bit large – so if you’re not really in to huge bags this may perhaps be far better as an over-night diaper tote.