Yes, you can have one index.php file and let it decide how to set the constant for each environment. More important is your database.php file. You should exclude database.php
from your GIT repository using methods like this:
Our current set up includes these branches:
/master
/test
/beta
We also have three server environments:
- Production
- QA
- Development
We are using a release system on SpringLoops to auto-deploy on beta
and test
branches, but to use a manual-deploy on the master
branch. That way, we are able to have an up-to-date version for development and QA testing (which matches our current build state), and to also be able to easily deploy our production code.
All of this uses the same exact code base except for the database.php
file.
Good luck!
Update: You shouldn't share dev
data with test/prod
data. You're likely to do things to your testing and prod data that is undesirable. This is also true for code and is why you should have 3 different copies of the code at any given time. Each copy is a safeguard against you overwriting yourself, and/or introducing a bug to production that can be found during development.
Therefore, your environment should be more like:
/root
/dev
/application
/assets
/system
index.php
/test
/application
/assets
/system
index.php
/public_html
/application
/assets
/system
index.php
Now, your GIT repo is only tracking anything under the /dev folder, because all three are copies of each other, only at different commit states.
Hope this all makes sense. One codebase. Three separate places to dev, test, then release to production.