Tuesday, November 1, 2011

Auto-Complete in Eclipse&Zend

[Try right click on project and see if there is Configure > Add PHP Support, If it is there use it]

This is a inference of mine while using Eclipse/Zend as IDE for PHP in linux [Not sure abt windows]

I was able to notice that PHP perspective over a SVN checked out PHP project didn't function as it was doing for a regular PHP project created via eclipse.
For Ex:
1. No syntax errors where highlighted/notified
2. CTRL press over a variable or a class or a function didn't give the option to navigate to the point its declaration
3. Autocompletion was completely disabled

After lots of searching, I figured out that whenever we create a project via eclipse, it will create two configuration files along with it

.project

.buildpath


SVN projects might have these files not being configured properly or might even miss them

So, inorder to overcome this, either you can create one by hand or create a new PHP project and export the files you checked out in to the newly created project.

Following are the sample configuration files. You can use them to create one by hand. Place the files in your project's root directory

.project
<?xml version="1.0" encoding="UTF-8"?>
  
    Your Project Name
    
    
    
    
        
            org.eclipse.wst.validation.validationbuilder
            
            
        
        
            org.eclipse.dltk.core.scriptbuilder
            
            
        
    
    
        org.eclipse.php.core.PHPNature
    
Including the previous file itself should fix the issue. If not then go on with this too. Select the correct path for the following file
.buildpath
<?xml version="1.0" encoding="UTF-8"?>

    
    

In linux these file will be by default hidden. Use CTRL+h to unhide them. If they don't exist then create new ones and restart your eclipse
Hope this helps :)