Sign up ×

Hi I'm looking for a Perl RESTful framework that have to :

  • work under apache2/mod_perl2
  • be simple
  • be elegant
  • be light
  • be flexible

Am I just dreaming or can I avoid the 'Roll our own' approach?

What framework would you recommend?

share|improve this question

closed as not constructive by Bill the Lizard Jun 13 '12 at 13:31


8 Answers 8

up vote 6 down vote accepted

I think you will find that Squatting ticks all those boxes!

I've written quite a few small RESTful apps with it. Its ideally suited for this and its been a pleasure to work with.

Here are some more links:

Here is a simple "hello world!" example:

use strict;
use warnings;

  package Simple;
  use base 'Squatting';

  package Simple::Controllers;
  use Squatting ':controllers';

  our @C = (
      Index => [ '/' ],
      get   => sub { 
        my ($self) = @_;
        my $v = $self->v;
        $v->{hello} = 'Hello World!';
        $self->render( 'hello' );

  package Simple::Views;
  use Squatting ':views';
  use HTML::AsSubs;

  our @V = (
    V(  'html',

      layout => sub { 
        my ($self, $v, @yield) = @_;
          head( title('Simple web app') ),
          body( @yield ),

      hello => sub {
        my ($self, $v) = @_;
        p( $v->{hello} );

Save above as in relevant place and make sure the following is in your Apache config:

  use Simple 'On::MP20';

<Location />
  SetHandler perl-script
  PerlHandler Simple->mp20

And away you go!

While here I would also give a passing mention to a couple of other frameworks which should fit the bill:

I say "passing mention" because I haven't used either of these and I'm not sure if either work (out of the box) with mod_perl2. Still with PSGI / Plack just around the corner this wouldn't be an issue for too long ;-)


share|improve this answer

I've used Dancer (github) for some smaller projects of mine. It's very elegant and very easy to get things done quickly with. It was inspired by the Ruby framework Sinatra.

It's as easy as:

#!/usr/bin/env perl
use Dancer;

get '/' => sub {
    'Hello world!'

share|improve this answer

Dancer is pretty well documented and trustable if you look at the test suite: ~500 tests that cover more than 80% of the source tree.

It's PSGI/Plack compliant and has few dependencies. The version 1.0 should be released very soon (maybe this weekend).

See the dancer website to stay tuned.

share|improve this answer

Another to consider would be Mojolicious which allows both writing and testing RESTful APIs in a very straightforward way.

share|improve this answer

My favorite Perl web application framework is CGI::Application. It is very lightweight (a single base class that you can inherit from) and does the bare minimum necessary to handle the repetitive tasks of web app programming and otherwise stay out of your way. You can use it in a formal MVC design, or do things more ad hoc if that's what you want.

It has a simple plugin architecture, allowing you to easily add support for Template Toolkit (HTML::Template is supported out of the box) sessions, authentication, JSON, streaming, and so on.

Finally, for creating REST-like friendly URLs, there is the excellent CGI::Application::Dispatch, which gives you a powerful rules-based engine for URL-based dispatch.

Also, despite its name, it works seamlessly under mod_perl 1 and 2.

share|improve this answer

Catalyst is a MVC framework that you can use to make Restfull services

  • It runs under apache2/mod_perl2
  • It is simple and elegant but IMHO not as much as most of the "new" MVC frameworks
  • Yeah .. it is light.
  • Dont think it is really flexible .. :( ..

EDIT: - The "new" frameworks I said are the ones that have good test frameworks to use (like rails/spring/Seam, with catalyst it is not easy to do tests besides the normal unit tests) and also a lot of developers working to build applications to them (the community around these frameworks are far more active). That's why I dont think Catalyst is really flexible too.

share|improve this answer
There's something wrong with your perception of Catalyst then. It's probably the most flexible of all of the various web frameworks out there. And I'm not sure why you think it's hard to test. –  singingfish Nov 4 '09 at 19:11
Catalyst, and in fact, most of the perl community relies on the ample test frameworks that come from Test::Builder, Test::Harness, and Test::More lineages. For functional testing of websites, there's Test::WWW::Selenium for the Selenium users among us, or for simpler non-ajaxy websites, Test::WWW::Mechaninze. All of these interfaces can then be layered inside an object oriented testing skeleton with classes like Test::Class, a fantastic xunit style testing framework. I'm not exactly sure what testing frameworks you're looking for, or if you're just not familiar with what's out there. –  Robert P Nov 4 '09 at 23:22
I'm not sure why you would not suggest Catalyst, it is very flexable, and with the move to Moose, is getting even more so. With Catalyst you can also build REST services really easily. See:…. As for testing goes, like the rest of Perl there is a lot of testing capabailty build into Catalyst. Take a look at… and related modules. All in all I would say catalyst is a good choice. –  gdey Nov 5 '09 at 4:41
+1 for Catalyst, but -1 for misplaced comment about flexibility/testability. –  RET Nov 5 '09 at 7:43
I don't think I've ever heard anyone call Catalyst "lightweight" before - even without the addition of Moose, it's long been CPAN's poster child for massive dependency chain horror stories. (And, if someone's complaining about dependency chains in something other than Catalyst, it's probably Moose they're complaining about, so Moosifying Catalyst won't help with that.) –  Dave Sherohman Nov 5 '09 at 10:32

I finally rolled my own pure mod_perl2 RESTful API dedicated framework:

Nothing is built-in except the essential. The rest is extensible (or will be). I had a look at all your suggestions, and they all seem to address too many things (DBI management, ORM, template engine, embedded server...).

That's why I wrote this one. I hope you'll find it useful.

share|improve this answer

Sorry about answering a bit late, but I described a REST framework in link text which has worked well for me. It makes adding new resources very simple; I barely have to write more than the resource-specific business logic; the framework takes care of the rest.

share|improve this answer
