NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
question - includes in files
Veteran

Joined: 16 Aug 2003
Posts: 101
Location: Montreal, Canada
Reply with quote
Hello,

please forgive me if this has been discussed/is obvious/belongs in the Request forum.

There are times when using "include" or "require" in a script requires an absolute path (as opposed to relative). For example, some scripts are executed by the php cgi on the server through cron jobs.

So, the problem is having local files with paths corresponding to a remote server. I wondered if there was a way to recognize these paths from the project mapping, and replace them on-the-fly with what they map to locally?

I am curious to know how people deal with deployment differences from local to remote versions. I'd appreciate any information about your workflow, and how you optimize your time and effort in that area.

Tx,

Martin
View user's profileFind all posts by mhSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
In case of cron-driven scripts, you run them using php cgi executable, I mean the case when no WEB server involved. In this case you can not use URL with appropriate arguments to request debug session.
So you can add DebugBreak() function call in the location where you want to start debugging. There is no other way to run debug session with remote CGI script. PHPEd projects are useless in this case. Using projects you can run either WEB-driven scripts (via URL) or local (you see _local_) CGI scripts.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Clarity
Veteran

Joined: 16 Aug 2003
Posts: 101
Location: Montreal, Canada
Reply with quote
Hi Dmitri,

sorry I wasn't clearer.

The script is executed both by the web server (regular web access) and by the php cgi (through cron), which explains the absolute path include.

Of course, I could always hack around the includes with some checks in the code, but it wouldn't be ideal. It would seem a pretty natural thing for phpED to do to apply project mappings to includes and requires...

Martin
View user's profileFind all posts by mhSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
But, really phped has this feature available on the mapping tab in the project settings.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Hmmm...
Veteran

Joined: 16 Aug 2003
Posts: 101
Location: Montreal, Canada
Reply with quote
I don't think we understand one another;

Say I have a file from a linux remote server with:

<?
include( "/usr/local/htdocs/website/include_file.php" );
?>

Project mapping:
URL: mywebserver
Remote Root: /usr/local/htdocs/website/

And local files are in C:\projects\website\

What would be nice is to be able to debug this script with local CGI or SRV, but the local parser chokes on the include because it does not recognize the path.

Basically, I'd like it to look for any "Remote Root" paths from include/require statements and replace them internally before passing these paths to the parser by local file paths such that as far as php is concerned, the include from above would look like:

include( "C:\projects\website\include_file.php" );

...and this would only happen with CGI or SRV, of course.

Am I making sense?

Tx,

Martin
View user's profileFind all posts by mhSend private message
Re: Hmmm...
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
mh wrote:
What would be nice is to be able to debug this script with local CGI or SRV, but the local parser chokes on the include because it does not recognize the path.

Actually, mapping makes sense while you're in HTTP/remote mode.
ONLY. For both CGI and SRV it does not make any sense.
So if you want to run your script on remote host you'd set HTTP/remote mode.
You don't need any additional setting for your project since include_file.php is already under the project's remote root and therefore will be mapped to C:\projects\website automatically.

Reverting back to CGI/local SRV modes. In this case neither dbg nor phped can help because php itself tries to find the target file in /usr/local/htdocs/website/include_file.php and certainly fails.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
question - includes in files
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