Re: Test Server to Live server - best way of handling different file paths in scripts?

From: Belmin (anonymous_at_nospam.com)
Date: 02/13/05


Date: Sun, 13 Feb 2005 06:44:13 GMT

The other replied were expired, how did you accomplish this? Curious

Written by "Dave Smithz" on 2/7/05 8:41p:
> Hi There,
>
> I have taken over someone else's PHP code and am quite new to PHP. I made
> some changes and have implemented them to a live environment fine so far.
>
> However, I now want to setup a test environment. All the PHP scripts start
> with a few lines of:
>
> require_once "library file at specific location on server"
>
> and when I move them from the test location to live location I have to
> manually apply the changes to each script to reflect the different paths for
> each server.
>
> I was thinking of writing a small script that is contained within the same
> folder as any folder that contains scripts that actually calls another
> require for that server .
>
> E.g.
> Have script do_something.php which I am developing regularly.
> On live server it starts with
> require_once "/home/live/phplib/library.php";
> On test server
> require_once "/home/test/phplib/library.php";
>
> Currently I apply a manual change this (via global change or whatever) when
> moving from Test to Live
> However, I might just change all requires to:
> require_once "./require.php";
>
> And then have a server specific version of require.php that contains the
> necessary requires for the particular server on which it resides.
>
> This way I can just change all the scripts to just require the require.php
> file in the same folder as itself. The actual PHP scripts where I do most of
> my updates need no changes whether on live or test servers.
>
> I just wanted to know if there was a better way of doing it then this. I
> know nothing about directives in PHP or if there was a way of determining
> the current server name and then calling different require commands
> appropriately.
>
> Any more elegant suggestions for handling this are welcome.
>
> Dave
>
>

-- 
Belmin Fernandez
Visit: http://www.belminfernandez.com/homepage
Email: belminf at gmail period com


Relevant Pages

  • Re: Dealing with PHP Files
    ... Dudley Henriques wrote: ... You can save any web page in Firefox, Command + S. If a web page has a .php ending this just means that the document that was loaded to the server had php code in it that he wanted parsed. ... The .php ending lets the server know to parse the php code in it There are other ways too). ... make a folder and put in the .php file and the folder with the images and maybe other things that FF made. ...
    (comp.sys.mac.apps)
  • Re: Dealing with PHP Files
    ... had php code in it that he wanted parsed. ... the server know to parse the php code in it There are other ways ... TextWrangler and save it as .html rather than .php, ... file and the folder with the images and maybe other things that ...
    (comp.sys.mac.apps)
  • Re: Web Server Botnets and Server Farms as Attack Platforms
    ... insecure web application written in PHP, although attacks for other ... The main reason for this is that many different PHP applications are ... and you've found your way to execute shell code on the remote web server. ... those scripts were put in place. ...
    (Bugtraq)
  • Re: Dealing with PHP Files
    ... You can save any web page in Firefox, Command + S. If a web page has a .php ending this just means that the document that was loaded to the server had php code in it that he wanted parsed. ... The .php ending lets the server know to parse the php code in it There are other ways too). ... If you go the source of the webpage via your browser, you will just see a text file with html mark up. ... make a folder and put in the .php file and the folder with the images and maybe other things that FF made. ...
    (comp.sys.mac.apps)
  • php mail() sendmail hanging
    ... When hitting php pages that use the mailfunction, I get a 5 second hang ... dnl Uncomment to allow relaying based on your MX records. ... This can allow sites to use your server as a backup MX without ... You can redirect all of the output of your scripts to a function. ...
    (freebsd-questions)

Loading