PSGI/Plack
Superglue interface between perl web application frameworks and web servers, just like Perl is the duct tape of the internet.
PSGI is an interface between Perl web applications and web servers. PSGI is inspired by Python's WSGI and Ruby's Rack.
Plack is a Perl module and toolkit that contains PSGI middleware, utility modules and adapters to PSGI servers.
The PSGI specification and Frequently Asked Questions are available.
What People Say
"I love this... I think it's exactly the right answer to what I was looking for, for a really simple webapp."
-Benjamin Trott, CTO and Co-founder of Six Apart
"Wow, this is nothing short of awesome. A big ++ to the entire PSGI/Plack team!"
-Stevan Little, Infinity Interactive, Moose author
"This is something we've needed for a long time: a clean and simple way to respond to HTTP requests without the cruft of CGI"
-Yuval Kogman, Infinity Interactive, KiokuDB developer
"PSGI (is) an absurdly simple, manifestly beautiful specification for an interface between Perl web apps and web servers."
-Patrick Donelan, WebGUI developer
"Thanks for including us! We're very excited about a future where we don't have to worry about web server support"
-Jonathan Swartz, Mason author
"I \N{HEAVY BLACK HEART} PSGI."
-Simon Cozens, the author of Advanced Perl Programming
"miyagawa++ # fucking awesome"
-Matt S Trout, Shadowcat Systems, Catalyst and DBIx::Class developer
Repositories
Servers
- Plack (adapters)
- Plack core includes HTTP::Server::PSGI, the standalone (prefork) HTTP server, a CGI runner (for running any PSGI application as a CGI script), a FastCGI daemon and Apache1 and 2 mod_perl handler.
- Misc Plack::Server adapters
- There are other PSGI server implementations and Plack adapters for them, to run PSGI applications on AnyEvent, FCGI::EV, Danga::Socket, Coro and POE. They are available as separate distributions.
- HTTP::Server::Simple::PSGI
- HTTP::Server::Simple::PSGI is based on HTTP::Server::Simple and has zero dependency other than HTTP::Server::Simple, which itself doesn't have any dependencies. This is best for embedding to build a standalone web server or dependency free frameworks.
- Nomo
- Nomo is a high-performance, superdaemon aware, preforking HTTP server that is compatible to PSGI. Using supervisors such as Server::Starter and ControlFreak, Nomo can benefit from features such as hot-deploy, graceful restart, dynamic worker pool configuration and UNIX socket sharing.
- ReverseHTTP
- ReverseHTTP server allows you to run a PSGI application on your desktop or inside the firewall but allows external access via reversehttp.net gateway.
- mod_psgi
- mod_psgi is an Apache2 module that runs PSGI applications using an embedded Perl interpreter. Developed by Jiro Nishiguchi
- evpsgi
- evpsgi is an evhttp based http server that runs PSGI applications with the embedded Perl interpreter. Developed by Masayoshi Sekimura
- Perlbal
- Perlbal::Plugin::PSGI allows you to run PSGI applications on Perlbal. Note that because Perlbal runs in a non-blocking event loop (Danga::Socket), your application is also not supposed to block. If your application blocks (with database acesss or network I/O), do not use this plugin and instead run your PSGI application with the prefork Plack server and reverse proxy to the backend as usual.
- nginx embedded perl
- Kazuhiro Osawa's nginx patches allows you to run PSGI applications on a Perl interpreter embedded inside nginx. This patch is considered highly experimental and not recommended for the production use. You're recommended to run your (possibly blocking) PSGI application with prefork/fastcgi servers and put nginx in front, and in that case you don't need this patch.
Frameworks
- Catalyst
- Catalyst is one of the most popular web application frameworks in Perl and has a support for PSGI through Catalyst::Engine::PSGI.
- CGI::Application
- CGI::Application is a CGI.pm-based lightweight web framework. Any CGI::Application based applications can run as a PSGI application using CGI::PSGI and CGI::Application::PSGI.
- HTTP::Engine
- HTTP::Engine is a micro web application framework and is a "father of PSGI/Plack" since we owe lots of code and ideas. HTTP::Engine itself now has PSGI Interface support as an adapter since 0.03 on CPAN.
- Dancer
- Dancer is a Sinatra-like micro web application framework and has supported PSGI since version 0.9904.
- Mason
- Mason allows you to embed code in HTML templates and can now run on any PSGI supported web server using HTML::Mason::PSGIHandler
- Squatting
- Squatting is a Camping-inspired Web Microframework and has a support for PSGI through Squatting::On::PSGI.
- Continuity
- Continuity is a Coro based web application libary that supports Continuations to build statefull applications and support PSGI via Coro server since version 1.1.1 on CPAN.
- Maypole
- Maypole is a Struts-inspired MVC web application frameworks built on top of Class::DBI ORM. Maypole applications can run as PSGI applications using Maypole::PSGI.
- Tatsumaki
- Tatsumaki is a web application framework built on top of Plack and AnyEvent: natively supports non-blocking I/O through psgi.streaming and psgi.nonblocking, non-blocking HTTP clients, long-poll Comet services and server push.
- Mojolicious
- Mojolicious is Merb and Sinatra inspired web framework and has zero dependencies to non-core Perl modules. It has a native PSGI adapter since 0.999915 on CPAN.
Applications
- WebGUI
- Patrick Donelan is working on Plack support for WebGUI on his github repo.
Middleware and Utilities
- CGI::PSGI
- CGI.pm subclass to handle PSGI env hash to provide a CGI.pm-compatible interface. Very useful to migrate CGI.pm-based web application frameworks to the PSGI interface.
- Plack::Request
- Plack::Request and Plack::Response is a simple wrapper around PSGI environment hash and response array to access those values using an Object oriented API.
- IO::Handle::Util
- Utility module to create an IO::Handle-like object instantly with a simple interface.
- HTTP::Parser::XS
- Super fast XS-based PSGI compatible HTTP header parser, used in many Plack server implementations.
- CGI::Emulate::PSGI
- Run any CGI scripts (whether it uses CGI.pm or not) as a PSGI application by emulating a CGI environment. It does the opposite of CGI runner PSGI server impementation (Plack::Server::CGI). Also take a look at CGI::Compile which compiles an existing CGI scripts into a callable subroutine reference, best to be used with CGI::Emulate::PSGI.
Slides and Blog Posts
Note that some materials and technical details might be outdated.
- Plack Advent Calendar
- 24 days of Tips and tricks for PSGI and Plack
- PSGI and Plack
-
- Tatsuhiko Miyagawa at London Perl Workshop, December 2009
- PlebGUI: WebGUI meets Plack
- Patrick Donelan writes a good introduction for PSGI and Plack from the web application developers point of view.
- I finally get PSGI and Plack!
- Simon Cozens writes a great post about what PSGI is, by comparing it with HTTP::Engine.
- Tatsumaki, Plack based non-blocking framework
- Tatsuhiko Miyagawa explains psgi.streaming interface to enable asynchronous requests in web frameworks. Screencast in Japanese is also available.
- PSGI/Plack
- Tokuhiro Matsuno and Tatsuhiko Miyagawa at YAPC::Asia 2009 (Japanese).
Tatsuhiko Miyagawa's blog and delicious bookmarks (PSGI and Plack) have a lot of updated information and links to PSGI/Plack related entries. We're chatting on #plack on irc.perl.org and have a low-traffic mailing list.