Welcome Guest, Not a member yet? Register   Sign In
devMode - small plugin for site-wide development ease

I created a tiny plugin that has one sole purpose - to be able to tell you if your site is running on a development, test or production server, based on the current domain.

For some reason, it took me a long time to get around to writing this. I've been thinking about something like this for a couple of months. Probably because it was so small I couldn't convince myself it was necessary. However, I've been reworking how I handle assets and, combined with a couple minor irritations every time I move to the live server, I figured it was time.

This is really handy in conjunction with a base_url configured to automatically detect your current domain:

$config['base_url']    = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];

(NOTE: I don't take credit for this line. I found it on the forums a long time ago and have been using it ever since.)

This is where devMode kicks in. In the database config file, you can setup different database connections. This is the perfect opportunity to setup your development, test (if you have one), and production server connections and information. Then, when the site is loaded, the base_url is set based on the actual domain it's running under, and you use devmode to set your database connection:

$active_group = devmode();

It also comes in handy in your asset management systems to automatically determine whether or not to combine/minify/etc.

It's a little thing, but I hope that it makes your programming life just a tiny bit easier and less stressful. Comments and suggestions are encouraged.

Download it at: http://igniteyourcode.com/devmode

Theme © iAndrew 2016 - Forum software by © MyBB