Mojolic...::Config(3)
π Mojolicious::Plugin::Config (3) β the Perl-ish config plugin, bestie edition
okay so real talk, this whole page is about Mojolicious::Plugin::Config from the User Contributed Perl Documentation, and it's genuinely one of the cutest little plugins you'll ever meet. it's a Perl-ish configuration plugin and it's about to make your config files slay. π
πΈ NAME πΈ
Mojolicious::Plugin::Config β Perl-ish configuration plugin. that's it, that's the name, no cap. β¨
π¦ SYNOPSIS π¦
ok so first up, your config file is literally just Perl returning a hash β icon behaviour, honestly:
# myapp.conf (it's just Perl returning a hash)
{
# Just a value
foo => "bar",
# Nested data structures are fine too
baz => ['β₯'],
# You have full access to the application
music_dir => app->home->child('music')
};
then with Mojolicious:
# Mojolicious
my $config = $app->plugin('Config');
say $config->{foo};
and with Mojolicious::Lite:
# Mojolicious::Lite
my $config = plugin 'Config';
say $config->{foo};
in a template, like foo.html.ep:
# foo.html.ep
%= config->{foo}
and the config is available application-wide, which is the main character energy we deserve:
# The configuration is available application-wide
my $config = app->config;
say $config->{foo};
and yes, everything can be customized with options π :
# Everything can be customized with options
my $config = plugin Config => {file => '/etc/myapp.stuff'};
π§ DESCRIPTION π§
okay so Mojolicious::Plugin::Config is a Perl-ish configuration plugin. putting that on a t-shirt fr fr.
the application object can be accessed via $app or the "app" function, and strict, warnings, utf8 and Perl 5.16 features are automatically enabled. you don't have to do anything, it just does it. obsessed. π«Ά
a default configuration filename in the application home directory will be generated from the value of "moniker" in Mojolicious, and that filename is $moniker.conf. and the way that you can extend the normal configuration file $moniker.conf with "mode" specific ones like $moniker.$mode.conf? those get detected automatically. iconic. β¨
β these configuration values are currently reserved, so don't go messing with them:
"config_override"β if this configuration value has been set in"config"in Mojolicious when this plugin is loaded, it will not do anything besides loading deployment specific plugins. that's the whole vibe, it just sits there."plugins"β one or more deployment specific plugins that should be loaded right after this plugin has been loaded. like so:
plugins => [{SetUserGroup => {user => 'sri', group => 'staff'}}]
the code of this plugin is a good example for learning to build new plugins, and you're welcome to fork it β go off, honestly. π
also see "PLUGINS" in Mojolicious::Plugins for a list of plugins that are available by default.
β¨ OPTIONS β¨
Mojolicious::Plugin::Config supports the following options. yes, all of them, we're covering everything, no skipping. π
π default
# Mojolicious::Lite
plugin Config => {default => {foo => 'bar'}};
default configuration, making configuration files optional. so if there's no file, you still get your lil defaults. lowkey genius.
π ext
# Mojolicious::Lite
plugin Config => {ext => 'stuff'};
file extension for generated configuration filenames, defaults to conf.
π file
# Mojolicious::Lite
plugin Config => {file => 'myapp.conf'};
plugin Config => {file => '/etc/foo.stuff'};
path to configuration file, absolute or relative to the application home directory, and it defaults to the value of the MOJO_CONFIG environment variable or $moniker.conf in the application home directory. pick your fighter. π
π METHODS π
Mojolicious::Plugin::Config inherits all methods from Mojolicious::Plugin and implements the following new ones. so you get the whole inheritance situation plus these lil extras.
π¦ load
$plugin->load($file, $conf, $app);
loads configuration file and passes the content to "parse". like a relay race but for data.
sub load ($self, $file, $conf, $app) {
...
return $self->parse($content, $file, $conf, $app);
}
π¦ parse
$plugin->parse($content, $file, $conf, $app);
parse configuration file. that's the job.
sub parse ($self, $content, $file, $conf, $app) {
...
return $hash;
}
π¦ register
my $config = $plugin->register(Mojolicious->new);
my $config = $plugin->register(Mojolicious->new, {file => '/etc/app.conf'});
register plugin in Mojolicious application and merge configuration. merging, bestie, it's giving teamwork. π«Ά
π SEE ALSO π
- Mojolicious
- Mojolicious::Guides
- <https://mojolicious.org>
π and that's the whole page, bestie! this one wasperl v5.42.0, dated2026-07-15, from the User Contributed Perl Documentation, and it belongs toMojolic...::Config(3). go build something cute with it πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms