Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Assist with Eclipse and PHP Standard/Core Functions

I have been working for 6 hours trying to get my standard core functions of PHP working with Eclipse 3.6 and PDT 2.2.1. For some reason, functions like echo, empty() and isset() come up on code completion, but functions like strtotime() and array_push() do not, even when I push CTRL+SPACE. Also, the function mysql_connect() comes up in the code assist, but mysql_query does not.

I have looked in several google search results and stackoverflow Q&As and found many solutions similar to this one:

Code completion/assist for built-in PHP functions in Eclipse PDT

I have made sure that my .buildpath looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
    <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
    <buildpathentry external="true" kind="lib" path="/Applications/MAMP/htdocs/harvestopia"/>
    <buildpathentry external="true" kind="lib" path="/Applications/MAMP/bin/php/php5.3.6"/>
    <buildpathentry external="true" kind="lib" path="/Applications/MAMP/htdocs/yharvestopia/YiiRoot/framework"/>
    <buildpathentry kind="src" path=""/>
</buildpath>

My .project looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>harvestopia</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.dltk.core.scriptbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.maziarz.yiiclipse.builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.php.core.PHPNature</nature>
        <nature>org.maziarz.yiiclipse.nature</nature>
    </natures>
</projectDescription>

My .settings/org.eclipse.php.core.prefs looksl ike this:

#Sat Nov 05 00:40:34 MDT 2011
eclipse.preferences.version=1
include_path=1;/Applications/MAMP/htdocs/yharvestopia/YiiRoot/framework

I am really banging my head against the wall and can really use some advice.

UPDATE: Without Yiiclipse, it still doesn't work. I created a new project in a new workspace called Test. The files look as follows but still do not allow for code assist on standard functions.

.project:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>test</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.dltk.core.scriptbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.php.core.PHPNature</nature>
    </natures>
</projectDescription>

.buildpath:

<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
    <buildpathentry kind="src" path=""/>
    <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

.settings/org.eclipse.php.core.prefs:

#Sat Nov 05 09:38:26 MDT 2011
eclipse.preferences.version=1
include_path=0;/test
like image 290
csalvato Avatar asked Feb 15 '26 23:02

csalvato


2 Answers

After 6 hours, I figured out something that works. I have no idea why this works, but it probably has to do with dependencies and other junk I don't understand right now.

What I did:

1) Uninstall Yiiclipse (left PDT installed) 2) Deleted all files out of my workspace 3) Created a new PHP project, for example "blog" in my web root 4) Using the yiic script, I created the new webapp in the blog folder 5) Opened Eclipse and refreshed the project. 6) Right clicked on the project->Build Path->Configure Build Path 7) Click on Link Source... 8) Linked to folder location webroot/YiiRoot/framework 9) Select "Update exclusion filters in other source folders to solve nesting"

Everything worked as intended.

like image 61
csalvato Avatar answered Feb 18 '26 11:02

csalvato


I found that installing PDT as dependency of yiiclipse cause the same problem (probably not all dependencies are included into yiiclipse). But if you uninstall yiiclipse, install PDT SDK plugin (from indigo updatesite) and again yiiclipse - code completion for std library functions works fine.

like image 33
kkrowa Avatar answered Feb 18 '26 11:02

kkrowa



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!