[Phpwm] PHP eclipse problem

pete graham petegraham1 at gmail.com
Wed Apr 26 09:36:38 BST 2006


Elliot,

Here is a better explanation of how I structure my code. In the eclipse
project I wanted to set projectname as the root directory.

Now projectname/htdocs is the webroot. Every single file in htdocs includes
a file called config.inc.php. The file includes this code:

if(preg_match("/WINDOWS/i", $_SERVER["SystemRoot"]))
{
    // THIS IS A WINDOWS MACHINE

    ## Include paths
    $_PATHS["base"]            = dirname(dirname(__FILE__)) . "\\";
    $_PATHS["includes"]        = $_PATHS["base"] . "includes\\";
    $_PATHS["templates"]    = $_PATHS["base"] . "templates\\";
    $_PATHS["pear"]            = $_PATHS["base"] . "pear\\";
    $_PATHS["logs"]            = $_PATHS["base"] . "logs\\";
    $_PATHS["sidebar"]        = $_PATHS["base"] . "sidebar\\";

    /**
    * Set include path
    */
    ini_set("include_path",

".;$_PATHS[includes];$_PATHS[templates];$_PATHS[pear];$_PATHS[sidebar]");

}else{
    // NOT A WINDOWS MACHINE (Linux, Mac, FreeBSD)

    ## Include paths
    $_PATHS["base"]            = dirname(dirname(__FILE__)) . "/";
    $_PATHS["includes"]        = $_PATHS["base"] . "includes/";
    $_PATHS["templates"]    = $_PATHS["base"] . "templates/";
    $_PATHS["pear"]            = $_PATHS["base"] . "pear/";
    $_PATHS["logs"]            = $_PATHS["base"] . "logs/";
    $_PATHS["sidebar"]        = $_PATHS["base"] . "sidebar/";

    /**
    * Set include path
    */
    ini_set("include_path",

".:$_PATHS[includes]:$_PATHS[templates]:$_PATHS[pear]:$_PATHS[logs]:$_PATHS[sidebar]");
}

this lovely bit of code means that I don't have to type:

include_once("../includes/functions.php");

I can just do this instead:

include_once("functions.php");

Unfortunately eclipse does not seem to enjoy this style of structuring which
is a shame because I find it highly effective.

I shall have to look into your suggestion of using a problems filter, that
sounds promising.

Pete



On 4/26/06, Elliot Smith <elliot at townx.org> wrote:
>
> Dear Pete,
>
> Although I don't organise my code like this, from what I know of
> PHPEclipse, it should resolve paths correctly if you did your includes
> something like this (presuming you set projectname as the root directory
> when creating your Eclipse project):
>
> require_once('../includes/file.php');
>
> I assume you're doing something like this, rather than using absolute
> paths? Another approach may be to just exclude those messages from the
> problems list using a filter.
>
> Elliot
>
>
> pete graham wrote:
>
> > I have been experimenting with PHPeclipse yesterday and today. Here is
> > a fairly big problem that I have run into that has stopped me from
> > using it.
> >
> > Eclipse generates a lot of warnings of type: "Include filename
> > 'blah.php' doesn't exist in project."
> >
> > I tried to explicitly set the "Include Path" for the project in
> > "Project->Properties->PHP Project Settings->Include Paths" (although
> > this shouldn't be necessary because these paths are dynamically set by
> > a set_include_path() call in the script). This hasn't solved the
> problem.
> >
> > All my projects have this structure
> >
> > projectname/htdocs/        # actual website root
> > projectname/includes/      # mostly php classes and files
> > with programming logic
> > projectname/templates/   # html files, headers footers, etc
> >
> > I find this an effective way of organising the files. It seems the
> > only way to get PHPeclipse to not generate the errors is to place all
> > code in the website root which I really don't want to do. Can anyone
> > help me on this problem?
> >
> > I saw on a forum post that "working sets" may be able to solve my
> > problem, but I'm quite unclear on what these are.
> >
> > Pete
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Phpwm mailing list
> >Phpwm at mailman.lug.org.uk
> >https://mailman.lug.org.uk/mailman/listinfo/phpwm
> >
> >
>
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/phpwm/attachments/20060426/47baab79/attachment.html


More information about the Phpwm mailing list