Back in the days when i was working on Catalyst, i thought it would be a great idea to have a special debug environment.
You could activate it with a simple -Debug flag in the import list.
But what if your development process has more stages than development and production?
Right, you are screwed.
That's why we've decided to use a more ambitious concept we call Modes in Mojolicious, where you can have an unlimited number of different environments.
package MyApp;
use base 'Mojolicious';
sub production_mode {
my $self = shift;
# Production templates
$self->renderer->root('/Users/production/templates');
}
sub development_mode {
my $self = shift;
# Development templates
$self->renderer->root('/Users/dev/templates');
}
sub startup {
my $self = shift;
# Default templates for everything else
$self->renderer->root('/Users/defaul/templates');
}
1;
As you can see we've chosen a very minimalistic approach that feels in line with the rest of Mojolicious.
Switching between modes is as easy as changing a environment variable.
% MOJO_MODE=production bin/my_app daemon
That is very clean and slick.