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 Dancer2

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

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.

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

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

Starting to dance

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

Note that a Dancer startup script is also a PSGI application.

Learning more moves

Resources to learn more:

Books about Perl Dancer

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:

Fork me on GitHub