Fork me on GitHub

A next generation web framework for the Perl programming language.

Back in the early days of the web, many people learned Perl because of a wonderful Perl library called CGI. It was simple enough to get started without knowing much about the language and powerful enough to keep you going, learning by doing was much fun. While most of the techniques used are outdated now, the idea behind it is not. Mojolicious is a new attempt at implementing this idea using state of the art technology.

Features

Installation

All you need is a one-liner, it takes less than a minute.

$ curl get.mojolicio.us | sh

We recommend the use of a Perlbrew environment.

Getting Started

These three lines are a whole web application.

use Mojolicious::Lite;

get '/' => {text => 'I ♥ Mojolicious!'};

app->start;

To run this example with the built-in development web server just put the code into a file and start it with "morbo".

$ morbo hello.pl
Server available at http://127.0.0.1:3000.

$ curl http://127.0.0.1:3000/
I ♥ Mojolicious!

Duct tape for the HTML5 web

Web development for humans, making hard things possible and everything fun.

use Mojolicious::Lite;

# Route connecting "/" with a template in the DATA section
get '/' => 'index';

# WebSocket service scraping information from a web site
websocket '/title' => sub {
  my $c = shift;
  $c->on(message => sub {
    my ($c, $url) = @_;
    my $title = $c->ua->get($url)->res->dom->at('title')->text;
    $c->send($title);
  });
};

app->start;
__DATA__

@@ index.html.ep
% my $websocket = url_for 'title';
<script>
  var ws = new WebSocket('<%= $websocket->to_abs %>');
  ws.onmessage = function (event) {
    document.body.innerHTML += event.data;
  };
  ws.onopen = function () {
    ws.send('http://mojolicio.us');
  };
</script>

Single file prototypes like this one can easily grow into well-structured applications.

Want to know more?

Take a look at our excellent documentation!