DEV Community


Posted on


Dancer2 is a light-weight web framework in Perl. Dancer2 is simple but extremely powerful to develop complex web applications. It opts for a handful of modules to start developing web projects.

Before starting the Project in Dancer2, the following are the prerequisites for this tutorial:

  1. Perl version 5.24 or greater installed on your local machine. On Unix or Mac Operating System, Perl is available through the default OS installation packages, if you are using the windows machine, install it from here.

  2. Elementary knowledge of Perl (Not Object Oriented) is essential. If you are not accustomed to basic Perl, then you are not ready for this tutorial. I would recommend acquiring fundamental knowledge of Perl first and continue the tutorial.

  3. Basic knowledge of HTML, CSS, Bootstrap(Optional).

Installation of Dancer2

You are over here!!! You fulfilled all the prerequisites to get started with Dancer2 Application. Great!!!

Let’s start with the Dancer2 Installation.

From the Command line terminal,

sudo cpan install Dancer2
Enter fullscreen mode Exit fullscreen mode

This command will install the Dancer2 on your local machine.

Alternate way of installing it on Unix or Unix-like systems:

sudo wget -O - | sudo perl - Dancer2
Enter fullscreen mode Exit fullscreen mode

The previous command will also work on Windows after installing CygWin.

If Operating system is Debian/Ubuntu, Dancer2 is available as repository package.

sudo apt-get install libdancer2-perl
Enter fullscreen mode Exit fullscreen mode

Quick Start Project in Dancer2

From the terminal execute the following:

dancer2 -a PForums
Enter fullscreen mode Exit fullscreen mode

It creates a web Application in dancer2, **PForums** is the name of our Application. Along with the Project Folder, it creates the Skeleton of the Project to develop more Complex Web Application if required.

Typical Dancer2 Project Skeleton looks like:


In Dancer2 framework, one line is enough to create the Project. Isn’t is easy?

Application Launch

Dancer2 is a PSGI web application framework, plackup tool is used for launching the application.

→ Go to the Project Folder (PForums in our case.)

plackup -a bin/app.psgi
Enter fullscreen mode Exit fullscreen mode

Command starts the Web Server at 5000 port.
HTTP::Server::PSGI: Accepting connections at http://0:5000/

Go to the browser and launch http://localhost:5000/


Congratulation, you launch your first Dancer2 Web App.

In this tutorial we learn:

✔ Dancer2 Introduction
✔ Dancer2 Installation
✔ Setting-up the Project
✔ Launch the web application.

Top comments (1)

choroba profile image
E. Choroba

I would recommend Strawberry Perl instead of Active State for MSWin.

Also, using sudo cpan is usually not needed if you don't want the modules available to everyone on the machine, Using local::lib for a single user is more lightweight and less dangerous.