If you don’t know, I’m a big ExpressionEngine fan (although my blog is on WordPress, I know). One of the best features or add ons or whatever you may call it is a master config file which will help a lot of aspects of development, but especially with running EE in multiple environments.
As with ExpressionEngine’s core team, Focus Lab recommends installing and running EE with some files ‘above the webroot’. This includes Focus Lab’s master config file, which is set up by default to run above the webroot.
However, I’m in a situation now where my client has a cheap shared hosting service (his choice, not mine), where we don’t have access to put anything above the webroot. This is likely the case for many, but I still wanted to use the master config files for version control, and development workflow. But it’s easy to alter, in only three short little lines of code.
Change in config.php
One of the instructions is to copy over a line of code to add at the bottom of config.php. The line looks like this:
require $_SERVER['DOCUMENT_ROOT'] . '/../config/config.master.php';
Now, to get this to work with having the /config/ folder within your webroot, simply remove the ‘/..’ from the line. The result should read:
require $_SERVER['DOCUMENT_ROOT'] . '/config/config.master.php';
Change in database.php
One more instruction has you copy over the database.php file to override the default file. There is an identical line of code in there to change on line 16.
Change in config.master.php
Finally, the last change, which has me tripped up for a minute or two, is the same change, but in the config.master.php file which is in the config folder you copied over from GitHub. On line 235, we need to make that exact same change (removing the ‘/..’) from the URL and that’s it!
Now I won’t condone running this from within the webroot because there are security issues, as EllisLab warns. It may not be the best practice, but sometimes when you don’t have access to the ‘above the webroot’ area, you’ve gotta do what you’ve gotta do!
Questions? Leave ‘em in the comments.