1

In my live site I have php include() and require() that have full path such as: /www/mysite.com/webapps/mmh/head.php or /www/mysite.com/webapps/ROOT/zip/BoundaryWizard.php

Now, I want to do some local development on my windows machine (Xampp), so obviously none of those path work.

Is there a way to tweak the apache or php settings to dynamically translate say /www/mysite.com/webapps/mmh/ to c:\xamp\mysite\some_other_arbitrary_folder ?

I assume the best way would be to have used relative paths is the first place, but this is legacy code, could take a while to fix ...

1
  • 3
    Not an answer, but in the future consider defining a ROOT_PATH constant to avoid these kinds of issues. Commented Oct 28, 2009 at 19:06

5 Answers 5

2

The right answer here (sorry) is that you should fix it. Have a common file where you declare a variable/contanst which is used to specify the path.

C'mon, it's not that hard. sed or any semi-good IDE will make changing a string on a bunch of files an easy task.

Sign up to request clarification or add additional context in comments.

Comments

0

You should define() your application path and then use find and replace in a text editor, most editors have that feature.

1 Comment

This means the code running in the development environment can't run unmodified in production, or test etc., environment. Better keep your code working in each environment and use a single configuration file to put these settings, plus things like database connection parameters etc.
0

If you don't want to change your code then create those directories.

You're in trouble if you ever have to switch hosts, so I'd recommend changing the code.

Comments

0

I'd think that a search/replace wouldn't hurt too much in this case, as it's not difficult.

The other thing you could do is to move your DocumentRoot so that it's at C:\www\mysite.com...

Comments

0

Maybe is not the best solution but for a not so clever solution you can use a simlink (I don't know how it is called in windows systems, maybe just links?).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.