Plack::Runner(3)

✨ NAME ✨

Plack::Runner β€” it's literally the core of plackup bestie πŸ’…


🌸 SYNOPSIS 🌸

# Your bootstrap script
use Plack::Runner;
my $app = sub { ... };

my $runner = Plack::Runner->new;
$runner->parse_options(@ARGV);
$runner->run($app);

πŸ’– DESCRIPTION πŸ’–

Okay so Plack::Runner is the actual heart of the plackup runner script. Like, plackup is the fit but this is the personality, yk? 🫢

You can build your own frontend to run your application or framework β€” munge up those command line options however you want and hand them straight to the run method of this class. Girlboss behaviour, honestly.

The run method does exactly the same thing as the plackup script does, fr fr β€” but there's one notable little addition that's lowkey iconic: you can pass a PSGI application code reference directly to the method, instead of going through a .psgi file path or using the -e switch. Bestie that is SO useful if you want to make an installable PSGI application. Obsessed. 😭✨

Also!! When the -h or --help switch gets passed, the usage text is automatically extracted from your own script using Pod::Usage. It just knows. Main character energy tbh. πŸ‘‘


πŸŽ€ NOTES πŸŽ€

Do NOT directly call this module from your .psgi, okay?? Because that makes your PSGI application unnecessarily depend on plackup and it won't run other backends like Plack::Handler::Apache2 or mod_psgi. And we are not doing that to ourselves. πŸ’€

If you really want to make your .psgi runnable as a standalone script though, you can do this:

my $app = sub { ... };

unless (caller) {
    require Plack::Runner;
    my $runner = Plack::Runner->new;
    $runner->parse_options(@ARGV);
    $runner->run($app);
    exit 0;
}

return $app;
WARNING: 🚨 this section used to recommend if (__FILE__ eq $0) but it's known to be broken since Plack 0.9971, because $0 is now always set to the .psgi file path even when you run it from plackup. So like… don't do that one bestie, it's giving deprecated-and-broken πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

  • plackup β€” go say hi, it's the sibling πŸ’œ

k that's the whole page bestie, slay ✨ This was Plack::Runner(3) from the User Contributed Perl Documentation, running on perl v5.42.3, dated 2026-10-18 β€” mwah, no cap, periodt. πŸ’…πŸŒˆ

πŸ“¦ where this page comes from