Skip to content

Dancer

Official Website: http://perldancer.org

Official Deployment Guide: http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod

Blurb:

Dancer is a web application framework designed to be as effortless as possible for the developer, taking care of the boring bits as easily as possible, yet staying out of your way and letting you get on with writing your code.

Dancer aims to provide the simplest way for writing web applications, and offers the flexibility to scale between a very simple lightweight web service consisting of a few lines of code in a single file, all the way up to a more complex fully-fledged web application with session support, templates for views and layouts, etc.

If you don’t want to write CGI scripts by hand, and find Catalyst too big or cumbersome for your project, Dancer is what you need.

How:

Dancer supports PSGI, so follow the local::lib and PSGI/Plack instructions first. Then install Dancer:

cpanm Dancer

Hello World

Create a test dancer web app (called “dancertest”) by running:

cd ~ # create webapp in your homedir, assuming your web-viewable folder is ~/www (or ~/public_html)
dancer -a dancertest # creates webapp in ~/dancertest

Note – there is a bug in Dancer version 1.1803 causing routes to work incorrectly under some versions of Apache. Hopefully by the time you read this the bug will be fixed, but in the meantime, edit ~/dancertest/lib/dancertest.pm and change the default route so that it matches all paths:

get r('.*') => sub {
    template 'index';
};

For the sake of this Hello World web app, that change will ensure that you get a valid response rather than a 404.

Install your new dancer app into your local lib:

cd ~/dancertest
cpanm .
cp -R ~/dancertest/public/* ~/www # copy public content into your web-viewable folder

CGI Mode
Dancer creates a file called dispatch.cgi that you can use to run your application in CGI Mode. All you have to do is follow the Plack CGI Mode instructions, using dispatch.cgi in place of app.cgi (on some shared hosts you might have better luck if you rename it to dispatch.pl).

FastCGI Mode
Dancer creates a file called dispatch.fcgi that you can use to run your application in FastCGI Mode. All you have to do is follow the Plack FastCGI Mode instructions, using dispatch.fcgi in place of app.fcgi.

Live Demos
http://hostmonster.perlsharedhosting.com/dancer

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS