What is Dancer?

Dancer is a simple but powerful web application framework for Perl

Key features

  • Dead Simple - Intuitive, minimalist and very expressive syntax
  • Flexible - PSGI support, plugins and modular design allow for strong scalability
  • Few dependencies - Dancer depends on as few CPAN modules as possible making it easy to install

Prepare your moves... and dance!

Dancer has been designed as a Perl web framework which is easy and intuitive to get to grips with - this is how easy it can be:

  •     #!/usr/bin/env perl
        use Dancer;
    
        get '/' => sub {
            "Hello World!"
        };
    
        dance;
        
  •     $ perl bin/app.pl &
        ...
        $ curl localhost:3000/
        Hello world!
        

Getting started with Dancer is easy, but it provides everything you need to write your web applications with ease!

Wide template support

Dancer can be used with a wide variety of templating systems, including:


    • Template Toolkit
    • Template::Flute
    • HTML::Template
    • Template::Tiny
    • Mason
    • Template::Alloy
    • HTML::CTPP2
    • Tenjin
    • Text::Haml
    • Text::Caml
    • Mojo::Template
    • Template::Declare

Support for many more template engines is available, and it's easy to write a Dancer::Template::* wrapper to add support for your favourite engine if it's not already available.

Easy database interaction

If you're using a Perl web framework, you want the easy stuff taken care of for you, so you can write the interesting stuff. The same applies to database access - it should be simple and non-tedious.

ORM with DBIx::Class

Dancer::Plugin::DBIC provides easy database access using DBIx::Class:

get '/profile/:id' => sub {
    my $user = schema->resultset('Users')->find(params->{id});
    ....
};

Or easy DBI database access

Dancer::Plugin::Database manages your database connections, providing an augmented DBI database handle for you to use:

get '/profile/:id' => sub {
    my $user = database->quick_select('Users', { id => $params->{id} });
    ...
};

Either way, we've got you covered.

Automatic serialisation for AJAX/APIs

Just enable one of the built-in seralizers and any references your routes return will automatically be serialised to JSON, XML, YAML - whatever you need. Use the Mutable serializer and the format can even be selected by the user making the request based on an "Accept" HTTP header.

ajax '/getloadavg' => sub {
    return {
        timestamp => time(),
        loadavg   => ( Unix::Uptime->load )[0],
    };
};

The above example simply returns a hashref from the route handler; the serializer takes care of turning it into the desired format (e.g. JSON) and returning it to the user.

(The example comes from the Dynamic AJAX charting with Dancer 2011 Advent Calendar post.)

Easy session support

Session support is in-built, with a wide choice of session storage methods:

  • YAML/Storable files on disc
  • Memcache
  • DBI
  • MongoDB
  • KiokuDB
  • Encrypted cookies

Extensible with plugins and engines

There's a wide range of plugins available on CPAN to provide useful extra features to make writing your applications even eaiser, and support for a wide range of template engines, logging methods, session storage methods, serialisers...

Just search CPAN and see!

  • 1.3 
  • You can also follow Dancer on GitHub and on Twitter

What people say about Dancer...


@PerlDancer is the easiest way to write webapps. One day from idea to implemention. Fantastic work. - alexkalderimis

I just spent yesterday with Perl Dancer and was able to get a website going for my Dad's software consulting company in no time at all! Thanks for all your efforts on Dancer it is pretty awesome. - Bryon Wickland

Dancer is the first web framework I haven't wanted to pee on :-) - Schwern

Perl Dancer is amazing! If you're into web development, definitely give Dancer a look, you might be surprised how fun and productive web development can be these days. Dancer is two things packed together: it stays out of your way if you like that, but also provides you with very powerful primitives to get the complex web tasks done in just a few lines of code. Highly recommended to both novices and experts! - linportal on reddit

I say I spent the afternoon on it, but @perldancer makes web dev so simple that it actually took about an hour. - Dave Cross (@davorg)

I like how dancer doesn't force you to code in any specific way, it provides the right amount of syntactic sugar to get your app up and running in double quick time - but doesn't get in the way when you want to do something else. It's nice and light, and can be deployed in many environments. Thumbs up from me! - James Aitken

Perl is [...] thriving and making some very cool new stuff while steadily negating the argument of being line-noise (Dancer comes to mind as an excellent project to both read and use). - dragonquest on Hacker News

Got my webservice up and running in 1 day with no knowledge about Dancer whatsover.[...] Dancer is excellent for middle size websites or web services. It doesn't get in your way, and supports a [...] lot of backend for deploying and running your application. The transition from developing a prototype to having a production ready app is very smooth. - Damian Krotkine

I’m really enjoying using Perl’s Dancer for building lightweight web applications. It’s heavily inspired by Ruby’s Sinatra framework, but clearly Perlish. - Joshua Barratt

Of all the light-weight frameworks, Dancer was the nicest to work with when I went through to evaluate them... - Daniel Pittman

Hacking around using @PerlDancer and enjoying it immensely. - deepakg

@PerlDancer Excellent framework! Thank you for making it easy for guys like me with two left feet who have to dance to make a living. - Rahul Kotamaraju (@rahul_k_v_)

Trying out @PerlDancer as a basis for building web apps. Very nice. - talexb

Dancer is the first web framework that hasn't given me an aneurysm. #perl - Michael G Schwern (@schwern)

[...] the words that come to mind are "quick", "small", "simple" and "clean". There's a close alignment of the packages and methods with the concepts one has in mind when doing web development. Formerly a Perl teacher, I never taught web development to the first-year students because the learning curve would have been too steep. I think Dancer has changed the game and beginners *can* learn Perl web development using Dancer. (We'll find out at the beginner's class I'm giving at YAPC in Riga:) - Andrew Solomon on cpanratings

For a simple framework I suggest Dancer. Great thing, it made me stop hating web development. - tsjr

Thanks to the @PerlDancer guys in IRC for their help.. better than any commercial support IMO - John Imison (@johnimison)

Just wrapped up an eight hour scrum task in 90 minutes. I'm really enjoying using Dancer. Awesome, awesome, awesome! - talexb

In the end I went with Dancer and I'm loving it so far - some more docs on the idiomatic way to deal with user creation, authentication and roles might be nice but I think I figured it all out pretty quickly. - Simon Wistow

...there's finally a web framework that works for me. It's called Dancer, and as redundant as this might sound; Dancer, is an effortless web framework. [...] It took me more time studying Dancer's features and specs, than the time it took for me to write the whole mini-blog app. - Carlos Ivan Sosa (gnusosa)

Dancer is a breath of fresh air in the convoluted world of Perl web frameworks. I have a lot vested in CGI::Application, another fine framework, but Dancer has really caught my fancy for future web apps. - punkish

Just downloaded and ran #Perl Dancer. Really curious about it. It looks amazing. - @juliofraire

I have - and would second frameworks like Perl Dancer as fantastic examples of what the Perl community is up to these days. - corn on Hacker News

Forgot to mention @twitpardy's backend is written in #Perl and website uses #Dancer. Props to the @perldancer team for the AWESOME software! - Mike (@mrpants)

Working on Perl Dancer and Extjs, wow, now programming is fun again! - James Michael DuPont (@h4ck3rm1k3)

@PerlDancer is probably the coolest framework I've used this year! - Miguel (@miguelcnf)

It's fast! It's simple! It's minimalistic! I really like it! Thanks. - Łukasz Metys Lewandowski

spacer
On Twitter: RT @maxgrp: @sukria @PerlDancer u can add t.co/Dd5u7DY5, And webservices at t.co/CtBg9yhX are based on Dancer as well.
spacer
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.