NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] Can't get doc root to stay put in a local project


Joined: 10 Jan 2008
Posts: 5
Location: Santa Cruz, CA
Reply with quote
[second hour using phped]...the first hour was spend on this: [can't find include files]

can-t-find-include-files-t4363.html

Sorry to bother everyone...but I don't have any spare hair to pull out...

Have this folder structure [jfg is the Project and is highlighted]

jfg
...css-folder
......user.css
...functions-folder
......display_header.php
......display_user_menu.php
...test-folder
......testmenu.php
...
...testmenu.php
...
=============
testmenu.php
<?
include("functions-folder/display_header.php");
include("functions-folder/display_user_menu.php");
display_header("test", "title");
display_user_menu("Profile","Summary");
?>
=============
display_header.php
<?
// output the html header
function display_header ($parent, $child) {
print ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."\n");
print ('<html>'."\n");
print ('<head>'."\n");
print ('<title>'.$parent.'-'.$child.'</title>'."\n");
print ('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n");
print ('<link href="css-folder/user.css" rel="stylesheet" type="text/css">'."\n");
...
=============
display_user_menu.php

// outputs a horizontal menu list with style defined in css-folder/user.css

=============

When I execute testmenu.php from the root directory the user.css file is found.
When I execute testmenu.php from a subfolder the user.css file is not found...and it shouldn't make a difference.

At first the included files in "functions" couldn't be found until I edited the php.ini file to include the path to the jfg folder.

What is wrong with this execution environment?

My project preferences say the root points to C:\jfgProject\jfg.

It appears that the root is being changed to the directory containing the file being run [where run starts]...which should not be the case.
The root should stay root...and all partial paths appended to the root.

Am I doing something really stipid... Embarassed ...[or expecting too much]?
View user's profileFind all posts by steverussSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Not sure but are you using the built in web server for your testing? That server is rather limited (enough functionality for testing some small things) so it *might* be possible that the server just changes to the directory containing the script and executes your script from there, which would explain the errors.
The "project root" is actually an alias for the initial working directory. If you are only testing 1 project you might want to edit php.ini and fill in the document_root there, perhaps that might help, or switch to a 3rd party server, if that is the problem.
View user's profileFind all posts by BlizzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
When I execute testmenu.php from the root directory the user.css file is found.
When I execute testmenu.php from a subfolder the user.css file is not found...and it shouldn't make a difference.


It certainly makes defference. Please check with php manual: http://www.php.net/include/
SRV server is not involved Smile


An excerpt from php manual:
Files for including are first looked for in each include_path entry relative to the current working directory, and then in the directory of current script.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Not [resolved]...still hoping for an explaination


Joined: 10 Jan 2008
Posts: 5
Location: Santa Cruz, CA
Reply with quote
dmitri...since you are the site admin...maybe you can find out WHO changed the title of this thread to [resolved]...which I find rude and inconsiderate.

You did not answer my question...no body has yet [sufficiently]. Thank you Blizz for taking a crack at it.

My question was about why the .css file wasn't found. That has nothing to do with php or includes...but with the webserver and html.

On almost all sites in the html header is a definition like this:
Code:
"<link href="css/common_v5.css" rel="stylesheet" type="text/css" />"

The link is a partial path...which is applied to the web root.

When I execute my test in PHPed it doesn't work to have the .css files in a folder in what I believe to be the /ROOT of this sudo webserver running in PHPed.

So maybe I still don't get IT. What does the entry in the project properties called "Root Directory" do for us? I assumed [maybe wrongly so] that when you run scripts within that project...the Root Directory is applied as the web root or /www or /public.html or whatever.

If that is not the case...do I have to start all of my scripts [using run/profile/debug] from a file located in the root of the "currently selected" project in order for PHPed to emulate the same action as on a web server?

Is PHPed setting the current working directory to the folder containing the file I am running/profiling/debuging in? Which means that any partial path will fail.
View user's profileFind all posts by steverussSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
The link is a partial path...which is applied to the web root.

Not at all. It's a relative path and is appended to the URL.

Quote:
When I execute testmenu.php from a subfolder the user.css file is not found...and it shouldn't make a difference

sorry, my answer was not accurate, neither php scripts nor phped project is involved.

Indeed, let's see what happans when a css file is referred with a relative path, like in your case.
If you open say test.html with http://somesite/test.html and it refers to css/my.css, my.css will be loaded from http://somesite/css/my.css
If you open test1.html located in a subdirectory, say http://somesite/subdir/test1.html and it also contains a referrence to css/my.css, latter one will be loaded from http://somesite/subdir/css/my.css
Hope it's clearer now.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
[resolved] Can't get doc root to stay put in a local project
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic