What is needed is quite simply two things
It probably doesn't need much explanation given the image to the right, and it may not be considered that good an idea so I'll stress that this is for a testing/development environment only.
So with a glance at the above image, it should be clear where I'm going. With a minor change to your /app/config/core.php file it is possible to modify you DEBUG constant if and only if you are in your development/test environment and there is a session variable set to override the default value:
Likewise a similar change to your /app/config/database.php file means that from your development/test environment you can dynamically switch database sources - this should be done with caution, if your production data isn't to be fiddled with it would be better to provide read-only access by restricting the appropriate database user:
With the above changes in place if you test you should find that... absolutely nothing changes. That's the desired result, as until now there has been no override set and as such the default values are taken which is what should be desired. So how do you change a value? Well all you need to do is have a means, any means, of setting a session variable, so how about this:
Now all that's needed is a means of calling the controller with a form, so with a config element like this:
... All the tools necessary to change debug and database settings are available at your finger tips.
With the code shown here, it should be possible to ensure that the appropriate constants and settings are set to speed up ad-hoc testing and debugging. Referring back to the original scenario, the developer could easily enter the debugging environment (which should be protected from public access) to find out what error has occurred that is not visible in the development environment - all without the possibility of a member of the public seeing potentially sensitive info on the screen and without taking the site completely offline to do so.
I hope that you found this useful, or at least it sparked an "O yeah, I could do..." type thought ;)