user2593042
user2593042

Reputation: 1

Pushing PHP code to multiple domains with slight changes

I have a simple web app that people use to keep track of golf scores. This same app is hosted on 4 different domains with 4 different databases. Changes made in one need to be made in all, since it's a collective refining process.

The code is almost identical except for slight changes like the DB connection, title of pages, and a header logo. That info is contained in an include file that is unique to each domain. All pages pull info from that.

What is the best practice for maintaining a single source code and uploading the same version to all domains??

Upvotes: 0

Views: 56

Answers (2)

Michael Schuenck
Michael Schuenck

Reputation: 57

In addition to a platform-specific solution, as provided by mirelon, a general approach could be based on Git branches. You could have a branch for the common features and branches for each publishable version. Each time you finish a change on a common feature (master branch), you merge it with the other branches.

An explanation and discussion on this topic can be found here: How to manage multiple versions of a project in Git.

Upvotes: 1

mirelon
mirelon

Reputation: 4996

It depends on the framework, but most frameworks use a config file with settings specific for a given environment.

For example, when using php with no framework, you can have a generic file settings-example.php with empty configuration values:

<?php
$settings['db_name'] = "";
$settings['db_pass'] = "";
// ...
?>

After each deployment create the environment specific file "settings.php" like this: cp settings-example.php settings.php and fill in values specific for the domain.

In a web app you can use:

<?php
require_once('settings.php');
// ... use variable $settings['db_name']

If you use a versioning system (git), add "settings.php" to .gitignore.

Upvotes: 0

Related Questions