Michelle
Michelle

Reputation: 2235

How to handle platform specific code under revision control

We have web developers on both Windows and Linux using SVN. Some PHP files reference a local path (e.g. Smarty/Geolocation libraries) and hence are different on their respective platforms. We need to keep these files under revision but the developers are starting to just add the svn:ignore attribute on these specific files to prevent conflicts. The only solution I can come up with is to put some code to determine which OS is being run but this seems like bloat for production code.

if (PHP_OS == "WIN32" || PHP_OS == "WINNT") {
        define('SMARTY_DIR', 'c:/xampp/smarty/');
    } else { 
        define('SMARTY_DIR', '/usr/local/lib/php/Smarty/');
    }

I'd love to hear how others have solved this problem.

Upvotes: 1

Views: 89

Answers (1)

vinnyjames
vinnyjames

Reputation: 2068

The typical way to do this is with a config.php.template file. The template file is version controlled and developers will copy it to config.php for their local settings.

Upvotes: 2

Related Questions