Setting Magento Developer Mode through htaccess file not working on shared hosting?

Why can't I get Developer Mode enabled through the htaccess file?
Why can't I get Developer Mode enabled through the htaccess file?

While following the "Weblog" demo found on Magento for Developers Part 5 - Models and ORM Basics from Magento Commerce, many people have been following the instructions to enable developer mode to intentionally throw errors when an include file is missing.

On MagePsycho .com there is a blog post suggesting seven steps to enable dev mode if you are having trouble. I followed those steps and still couldn't get it to happen.

It turns out that since my dev box is running on a shared hosting environment (1and1 in this case) I was subject to the "SetEnv" command not working in the .htaccess file. The way Developer Mode is supposed to work is that you first set the environment variable of "MAGE_IS_DEVELOPER_MODE" to any value and then the index.php checks that this environment value is in fact set (to anything) and enables dev mode.

In my case, with htaccess not able to set environment variables, the condition tests false. The fix was to change the following lines from index.php in the Mage core directory:

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}

...and either change the conditional to always work (perhaps add an "OR TRUE" to it), or...

...you could simply copy the middle line inside the conditional and paste it again outside of (either above or below) the conditional block. Either way, you should see the errors start reporting once you instruct that setIsDeveloperMode to fire off without a conditional check.

Tags: