Quick Start

Getting started with Dancer is easy - we hope you'll be surprised how simple, fun and flexible building a website in Perl with Dancer can be. Even if you're a newcomer to Perl, you should find the simple things easy, and hard things possible.

Installing Dancer

For easy and automatic installation of Dancer, we recommend using cpanminus:

curl -L http://cpanmin.us | perl - --sudo Dancer

Of course, you can use any other CPAN client to do so, or even install it by hand.

Creating an application

A Dancer application can be as simple as a one-liner, but you may want to start with a complete structure for more complex applications. To help you do so, dancer is shipped with a helper that can scaffold a new skeleton for you.

$ dancer -a MyWeb::App
+ MyWeb-App
+ MyWeb-App/bin
+ MyWeb-App/bin/app.pl
+ MyWeb-App/config.yml
+ MyWeb-App/environments
+ MyWeb-App/environments/development.yml
+ MyWeb-App/environments/production.yml
+ MyWeb-App/views
+ MyWeb-App/views/index.tt
+ MyWeb-App/views/layouts
+ MyWeb-App/views/layouts/main.tt
+ MyWeb-App/lib
+ MyWeb-App/lib/MyWeb
+ MyWeb-App/lib/MyWeb/App.pm
+ MyWeb-App/public
+ MyWeb-App/public/css
+ MyWeb-App/public/css/style.css
+ MyWeb-App/public/css/error.css
+ MyWeb-App/public/images
+ MyWeb-App/public/500.html
+ MyWeb-App/public/404.html
+ MyWeb-App/public/dispatch.fcgi
+ MyWeb-App/public/dispatch.cgi
+ MyWeb-App/public/javascripts
+ MyWeb-App/public/javascripts/jquery.js
+ MyWeb-App/Makefile.PL
+ MyWeb-App/t
+ MyWeb-App/t/002_index_route.t
+ MyWeb-App/t/001_base.t

Everything is ready and works out of the box (with a nice design, jQuery and environment-related configurations).

Starting to dance

$ cd MyWeb-App
$ ./bin/app.pl
>> Dancer server 16622 listening on http://0.0.0.0:3000
== Entering the development dance floor ...

Note that a Dancer startup script is also a PSGI application, so you can power it with any Plack backend, like plackup:

$ cd MyWeb-App
$ plackup ./bin/app.pl
HTTP::Server::PSGI: Accepting connections at http://0:5000/

See Dancer::Deployment for more ways to deploy your Dancer applications.

Learning more moves

Resources to learn more:

New to Perl, too?

If you're looking to learn to use Perl, we hope that the simplicity and ease of getting started with Dancer will be very helpful to you; however, you'll probably also want to find some decent tutorials and resources to learn about Perl itself. Do be wary of some of the results which Google will turn up - there's some very outdated and inadvisable tutorials out there.

The following is a short, non-exhaustive list of resources which are likely to be of use to Perl beginners:

On Twitter: Disabled
Fork me on GitHub