Turning debug off automatically in production
This article is over a year old and may contain outdated information.
So I recently got tired of having to manually set debug to 0 every time I updated an old site or published a new one. So I thought, why not have it automatically turn off when the site is live? For this to work, I'm assuming that you are working on a localhost with an IP of 127.0.0.1. If you are not, you might get this to work by changing the IP in the code below, or using HTTP_HOST instead of REMOTE_ADDR. Simply add this code at the top of your app/config/bootstrap.php file.
// Production
if (env('REMOTE_ADDR') != '127.0.0.1') {
Configure::write('debug', 0);
}
// Or alternate technique
if (env('HTTP_HOST') != 'localhost') {
Configure::write('debug', 0);
}
This also means you can leave debug set to 2 in your core config file at all times.
2 Comments
as 0 is and should be the default setting
but other than that