Elliot,<br><br>Thanks for the help on the filter that is working nicely now.<br><br>In response to your code comment:<br><br>1. I am well aware that I could make that piece of code could be made more efficient/elegant. It was originally written to just use on Linux servers, I had to quickly change it when developing using XAMPP on my laptop one day.
<br><br>2. Personally I prefer setting up the include path and using:<br><br>include_once("functions.php");<br><br><font size="2"><font size="2">I have being doing this for a while, if I remember correctly the reason I started doing it was because if you include a page from an include page, the 2nd include is relative to the original page not the page including it.
<br><br>I was finding this a bit irritating as I have actual pages at different levels of depth in the webroot that call classes (in the folder includes) that then include other functions (in includes), now with relative paths this was breaking my system as the relative position of the functions file changes. This was the solution I found. I'm not suggesting that everyone should use it, it just works for me.
<br><br></font></font>Your suggestion of a init style script, is interesting, I actually do a similar thing to call helpful/useful functions these days, which would actually solve the problem described above too ;-)<br><br>
Your Namespaces comment is also valid, I use a naming convention so everything in the includes folder has the extensions .inc.php or .class.php. Everthing in htdocs only has only the .php extension.<br><br>Pete<br><br><div>
<span class="gmail_quote">On 4/26/06, <b class="gmail_sendername">Elliot Smith</b> <<a href="mailto:elliot@townx.org">elliot@townx.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Pete,<br><br>A few comments:<br><br>1. Instead of having two separate, almost identical sets of code for<br>setting up the include path, it might be better to use the DIRECTORY<br>SEPARATOR and PATH_SEPARATOR magic PHP constants, like this:
<br><br>$_PATHS["includes"] = $_PATHS["base"] . "includes" .<br>DIRECTORY_SEPARATOR;<br>$_PATHS["templates"] = $_PATHS["base"] . "templates" .<br>DIRECTORY_SEPARATOR;
<br><br>...<br><br>ini_set("include_path", "." . PATH_SEPARATOR . "$_PATHS[includes]" .<br>PATH_SEPARATOR . "$_PATHS[templates]" ...<br><br>...<br><br>(truncated for brevity). That way you can set the paths for any OS with
<br>the same code.<br><br>2. I think it's a matter of taste whether you prefer:<br><br>include_once("../includes/functions.php");<br><br>OR<br><br>include_once("functions.php");<br><br>Personally, I prefer the former, as it is more explicit about where the
<br>code you're including resides. It's not so obvious in the latter, and<br>I'd prefer clarity over brevity any day. Plus there's less chance of<br>namespace clashes (e.g. if there is a functions.php file in more than<br>
one place on the include path, PHP might include the wrong one).<br><br>My personal tendency would be to create a single init style script,<br>which pulls in all the libraries I'm going to need, then just include<br>the init script where I need the libraries. I know this may pull in more
<br>code than I actually need for some scripts; but I think the extra time<br>spent doing this is probably little more than the extra time PHP would<br>spend resolving paths where they are not explicit (as is the case if you
<br>append lots of extra paths to the include_path ini variable).<br>Interesting one, though.<br><br>3. Filtering problem messages in Eclipse: get the Problems view up;<br>click the little button with arrows on it (top right); in the pop-up
<br>window, at the bottom, there's an option to filter problems shown, based<br>on text within the problem (exclude or include).<br><br>Elliot<br><br><br><br><br><br>pete graham wrote:<br><br>> Elliot,<br>><br>> Here is a better explanation of how I structure my code. In the
<br>> eclipse project I wanted to set projectname as the root directory.<br>><br>> Now projectname/htdocs is the webroot. Every single file in htdocs<br>> includes a file called config.inc.php. The file includes this code:
<br>><br>> if(preg_match("/WINDOWS/i", $_SERVER["SystemRoot"]))<br>> {<br>> // THIS IS A WINDOWS MACHINE<br>><br>> ## Include paths<br>> $_PATHS["base"] = dirname(dirname(__FILE__)) . "\\";
<br>> $_PATHS["includes"] = $_PATHS["base"] . "includes\\";<br>> $_PATHS["templates"] = $_PATHS["base"] . "templates\\";<br>> $_PATHS["pear"] = $_PATHS["base"] . "pear\\";
<br>> $_PATHS["logs"] = $_PATHS["base"] . "logs\\";<br>> $_PATHS["sidebar"] = $_PATHS["base"] . "sidebar\\";<br>><br>> /**
<br>> * Set include path<br>> */<br>> ini_set("include_path",<br>><br>> ".;$_PATHS[includes];$_PATHS[templates];$_PATHS[pear];$_PATHS[sidebar]");<br>><br>> }else{<br>> // NOT A WINDOWS MACHINE (Linux, Mac, FreeBSD)
<br>><br>> ## Include paths<br>> $_PATHS["base"] = dirname(dirname(__FILE__)) . "/";<br>> $_PATHS["includes"] = $_PATHS["base"] . "includes/";
<br>> $_PATHS["templates"] = $_PATHS["base"] . "templates/";<br>> $_PATHS["pear"] = $_PATHS["base"] . "pear/";<br>> $_PATHS["logs"] = $_PATHS["base"] . "logs/";
<br>> $_PATHS["sidebar"] = $_PATHS["base"] . "sidebar/";<br>><br>> /**<br>> * Set include path<br>> */<br>> ini_set("include_path",<br>>
<br>> ".:$_PATHS[includes]:$_PATHS[templates]:$_PATHS[pear]:$_PATHS[logs]:$_PATHS[sidebar]");<br>> }<br>><br>> this lovely bit of code means that I don't have to type:<br>><br>> include_once("../includes/functions.php");
<br>><br>> I can just do this instead:<br>><br>> include_once("functions.php");<br>><br>> Unfortunately eclipse does not seem to enjoy this style of structuring<br>> which is a shame because I find it highly effective.
<br>><br>> I shall have to look into your suggestion of using a problems filter,<br>> that sounds promising.<br>><br>> Pete<br>><br>><br>><br>> On 4/26/06, *Elliot Smith* < <a href="mailto:elliot@townx.org">
elliot@townx.org</a><br>> <mailto:<a href="mailto:elliot@townx.org">elliot@townx.org</a>>> wrote:<br>><br>> Dear Pete,<br>><br>> Although I don't organise my code like this, from what I know of
<br>> PHPEclipse, it should resolve paths correctly if you did your includes<br>> something like this (presuming you set projectname as the root<br>> directory<br>> when creating your Eclipse project):
<br>><br>> require_once('../includes/file.php');<br>><br>> I assume you're doing something like this, rather than using absolute<br>> paths? Another approach may be to just exclude those messages from the
<br>> problems list using a filter.<br>><br>> Elliot<br>><br>><br>> pete graham wrote:<br>><br>> > I have been experimenting with PHPeclipse yesterday and today.<br>> Here is
<br>> > a fairly big problem that I have run into that has stopped me from<br>> > using it.<br>> ><br>> > Eclipse generates a lot of warnings of type: "Include filename<br>> > '
blah.php' doesn't exist in project."<br>> ><br>> > I tried to explicitly set the "Include Path" for the project in<br>> > "Project->Properties->PHP Project Settings->Include Paths"
<br>> (although<br>> > this shouldn't be necessary because these paths are dynamically<br>> set by<br>> > a set_include_path() call in the script). This hasn't solved the<br>> problem.
<br>> ><br>> > All my projects have this structure<br>> ><br>> > projectname/htdocs/ # actual website root<br>> > projectname/includes/ # mostly php classes and files
<br>> > with programming logic<br>> > projectname/templates/ # html files, headers footers, etc<br>> ><br>> > I find this an effective way of organising the files. It seems the<br>
> > only way to get PHPeclipse to not generate the errors is to<br>> place all<br>> > code in the website root which I really don't want to do. Can<br>> anyone<br>> > help me on this problem?
<br>> ><br>> > I saw on a forum post that "working sets" may be able to solve my<br>> > problem, but I'm quite unclear on what these are.<br>> ><br>> > Pete<br>> >
<br>> >------------------------------------------------------------------------<br>><br>> ><br>> >_______________________________________________<br>> >Phpwm mailing list<br>> >
<a href="mailto:Phpwm@mailman.lug.org.uk">Phpwm@mailman.lug.org.uk</a> <mailto:<a href="mailto:Phpwm@mailman.lug.org.uk">Phpwm@mailman.lug.org.uk</a>><br>> > <a href="https://mailman.lug.org.uk/mailman/listinfo/phpwm">
https://mailman.lug.org.uk/mailman/listinfo/phpwm</a><br>> ><br>> ><br>><br>><br>> _______________________________________________<br>> Phpwm mailing list<br>> <a href="mailto:Phpwm@mailman.lug.org.uk">
Phpwm@mailman.lug.org.uk</a> <mailto:<a href="mailto:Phpwm@mailman.lug.org.uk">Phpwm@mailman.lug.org.uk</a>><br>> <a href="https://mailman.lug.org.uk/mailman/listinfo/phpwm">https://mailman.lug.org.uk/mailman/listinfo/phpwm
</a><br>><br>><br>>------------------------------------------------------------------------<br>><br>>_______________________________________________<br>>Phpwm mailing list<br>><a href="mailto:Phpwm@mailman.lug.org.uk">
Phpwm@mailman.lug.org.uk</a><br>><a href="https://mailman.lug.org.uk/mailman/listinfo/phpwm">https://mailman.lug.org.uk/mailman/listinfo/phpwm</a><br>><br>><br><br><br>_______________________________________________
<br>Phpwm mailing list<br><a href="mailto:Phpwm@mailman.lug.org.uk">Phpwm@mailman.lug.org.uk</a><br><a href="https://mailman.lug.org.uk/mailman/listinfo/phpwm">https://mailman.lug.org.uk/mailman/listinfo/phpwm</a><br></blockquote>
</div><br>