Re: Database includes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks to everyone who responded.  Some really interesting ideas.  I'll
try them out.


Regards,

Bruce

>>> "Wouter van Vliet / Interpotential" <wouter@xxxxxxxxxxxxxxxxxx>
28/08/2007 8:34 a.m. >>>
On 27/08/07, Stut <stuttle@xxxxxxxxx> wrote:

> I use a slightly different approach to prevent the need to mess
about
> with files when moving to production. At the end on config.php I
have
> this...
>
> if (file_exists('config_dev.php'))
>      require 'config_dev.php';


I've got my own variation on this, came to use it to prevent
overwriting
config files for stage/dev/live or other versions of a site. I've got
a
general purpose constants file, which defines a lot of constants which
are
generally used a lot in my applications (file rootdir, DAY, HOUR,
database
passwords, some regexes, these things). Instead of just defining them
there,
I define them using a simple conditional define function (if
(!defined($constantName) define($constantName, $value)). On top of my
constants.inc.php (as I chose to call it) I use the following:

if (isset($_SERVER['SERVER_NAME'])) {
    $_config_file =
dirname(__FILE__).'/../eg/'.$_SERVER['SERVER_NAME'].'.inc.php';
    @include($_config_file);
}

The included hostname specific config file would then define some
constants,
and because they are already defined the default values from
constants.inc.php don't get set anymore.

Hope this is of help to anybody, it has certainly relaxed my
deployment
process..

Wouter


In config_dev.php I override anything defined in config.php that needs
> to be different on the current server. The config_dev.php file is
*not*
> in source control so it doesn't exist in production but each
development
> and test environment has a version that modifies the production
> environment.
>
> There is a hit involved in the call to file_exists, but PHP caches it
so
> the effect is minimal.
>
> -Stut
>
> --
> http://stut.net/ 
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php 
>
>


-- 
Interpotential.com
Phone: +31615397471

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux