June 27, 2007

Svn, Linux server, XP dev box have different dir structure, how can I make includes system ignorant?

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).

  1. The files I check out (subversion) use explicit paths (the standard here) that don't translate to my local windows box.
  2. <?php require_once('c:/projects/proj… ?>
  3. Is there a way to have PHP automatically translate lines like:
  4. to work like:
  5. 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.

  6. <?php require_once('/www/project1/fi… ?>
  7. without having to manually change everything after each checkout and before each checkin?

Tags: ,

Tell a Friend Today!

del.icio.us Digg Furl Reddit Ask BlinkList blogmarks Blogg-Buzz Google Ma.gnolia Netscape ppnow Rojo Shadows Simpy Socializer Spurl StumbleUpon Tailrank Technorati Windows Live Wists Yahoo! Help

Permalink • Print

Track this entry

RSS BlogPulse

RSS Technorati Cosmos

Related Searches

, , , ,