Home » Php » Eclipse PDT Intellisense for PHP functions

Eclipse PDT Intellisense for PHP functions

Posted by: admin July 12, 2020 Leave a comment

Questions:

So the intellisense works for my own variables, methods, etc. but doesn’t work for php functions like in_array… I’m just opening a single PHP file instead of creating a project. It works when I create a PHP project and create a php file inside that project. But doesn’t work when opening individual php files.

VS.Php for VS2010 has intellisense for php functions when I just open a single php file. I’d like to emulate this functionality in Eclipse. Does anyone know how to make Eclipse PDT show php functions when opening a file?

Thanks.

How to&Answers:

Have you tryed netbeans for PHP? I’ve developed the past 2 years with netbeans+apache+php5+MySQL+MongoDB and used Netbeans all along on Ubuntu machines. The only thing it lacks at the moment is the code completion (intellisense) for the Mongo objects. Other then that it reads your code and complete PHP functions as well. And it’s built on top of Eclipse (or at least derived from Eclipse). I think it’s everything you’re looking for.

Cheers

Answer:

With Eclipse / Netbeans, you cannot have autocompletion on a single file without a project.

I use Notepad++ : in order to activate autocompletion go to “Settings” > “Preferences” > “Backup/Autocompletion” tab and check the option.

Answer:

As far as I know Eclipse doesn’t have such a functionality. Eclipse works well in a project context. As I understand it, when you create a PHP project in Eclipse, it adds the PHP core libraries in this specific context. This makes sense because Eclipse support many languages, I use it to develop in C, Java and PHP and I certainly don’t want all the libraries loaded at startup or each time I open a file.

To handle your issue, I created ‘default’ projects. I have ‘PHPDefault’, ‘JavaDefault’ and C++Default, each with appropriate settings and libraries. If you need to open a single PHP file from your OS, drag it to your project, if you want to open it from a remote location, copy it to your default project folder and refresh it from Eclipse so it will appear.

The is the only way I know, let me know if it works out for you.