English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm currently developing PHP applications on a Windows XP machine. I test everything locally (Apache 2 & php 5), but the live web server is linux (also Apache 2 & php 5).

The files I check out (subversion) use explicit paths (the standard here) that don't translate to my local windows box.

Is there a way to have PHP automatically translate lines like:

to work like:

without having to manually change everything after each checkout and before each checkin?

2007-03-27 07:00:10 · 1 answers · asked by wfinn 2 in Computers & Internet Programming & Design

1 answers

Well, if you can differentiate what system you are running on (e.g. get the hostname or IP and use that to determine if you are in test or prod mode) then you can set paths & other system dependent data (passwords, logon ids etc).

A better possibility is to write a query to pull that information out of a local database so when your code is in prod it gets the production values and when it is in test it gets test values.

Yet another possibility is to put the values into a require file in the same directory with the code you are writing and import it. However, this may not work for you as it seems your standards do not allow you to say "require_once("./settings.php");"

I have worked on a variety of platforms in a variety of settings and this is always a problem. You try to minimize it but it is often one runs into the need for hardcoding in values that differ between test & prod.

Oh one more idea. Develop on Linux instead of Windows.

2007-03-27 11:02:19 · answer #1 · answered by Wi-Skier 4 · 0 0

fedest.com, questions and answers