Perl web development

Perl Plack/PSGI

Plack/PSGI - simple and flexible web development

Improving web server choice and ease of development

Plack is Perl superglue for web frameworks and web servers. Plack sits between your code (whether you use a web framework or not) and the web server. This means that you (and your framework) do not need to worry about specifics of a web server, and vice-versa.

Want to try out a different web server? Check if there is a PSGI Handler for it. Over 15 different web servers are already supported, including Apache 1 and 2, Starman, FCGI and several standalone servers for testings. Then point it at your .psgi configuration file for your web application. That is it. Your application will now run under this completely new web server environment.

Other than being able to switch web servers easily, how else can Plack help you? There are already dozens of Plack::Middleware modules which add extra functionality in a generic way, be this for logging (choose where and what format your logs are in), debugging (built in and available for any site), serving static content and many other features. You can control which of these is activated depending on whether you are on a development or production server.

Plack also allows you to very easily run a standalone server. This makes development and debugging very fast because there are no extra dependencies or processes to run. Because your entire configuration is in your .psgi file you can be sure there are no extra side effects of how the web server has been setup.

Over 18 of Perl’s largest web framework projects already have support for Plack, and even if you don't use a framework implementing it is trivial.



Article Author

Leo Lapworth