Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require() and include() not working in Eclipse for code assist and autocomplete

Tags:

php

eclipse

ide

I just started using Eclipse PHP.

I finally figured out how to turn on auto complete code assist.

My problem is that when I use require or include, those variables in those files aren't showing up.

Example,

code1.php

<? $test = 'hi'; ?>

code2.php

<? require('code1.php'); ?>

When I am editing code2.php, $test variable doesn't show up in auto complete (aka code assist)

like image 620
shrimpwagon Avatar asked Jul 14 '26 02:07

shrimpwagon


1 Answers

In Eclipse 3.6 with PDT 2.2.1, I was able to solve this issue by going to:

Window->Preferences->PHP->Editor->CodeAssist

and then enabling "Show variables from other files", and clicking Apply.

This was the only way I could get the autocompletion to work for non-class-type variables defined in external files.

like image 80
Jason Frank Avatar answered Jul 15 '26 14:07

Jason Frank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!