5 comments

[ 4.1 ms ] story [ 26.2 ms ] thread
The proper way to do this is with branches, not with hard-coded logic
That's one option.

However the issue with that is if you have multiple environments (e.g. three test environments, staging and production) and you want to have the code in a state of continuous deployment, then you use your branch for your feature, merge it in with this feature switch and when it gets to staging and you realise there's a bug, you can simply switch the feature off without it causing an issue rather than having to remove code from a merge.

You shouldn't merge until you've tested and are fairly certain there isn't a bug. Bugs in staging shouldn't be common and fixes should be fairly quick and easy. That's what staging is for, after all.
I work in a code base that's 5 million lines of code. It happens.

That aside, it's very useful for launching features. I have used this practice at Expedia and works well.

This is also works well for launching a feature as it's a simple on/off switch - simply git ignore the features.php file to have a different one in each environment.