File: README.md

package info (click to toggle)
libmojolicious-perl 5.54%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,232 kB
  • ctags: 1,223
  • sloc: perl: 9,581; makefile: 10
file content (102 lines) | stat: -rw-r--r-- 3,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

# Mojolicious [![Build Status](https://travis-ci.org/kraih/mojo.svg?branch=master)](https://travis-ci.org/kraih/mojo)

  Back in the early days of the web, many people learned Perl because of a
  wonderful Perl library called [CGI](https://metacpan.org/module/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

  * An amazing real-time web framework, allowing you to easily grow single
    file prototypes into well-structured web applications.
    * Powerful out of the box with RESTful routes, plugins, commands, Perl-ish
      templates, content negotiation, session management, form validation,
      testing framework, static file server, first class Unicode support and
      much more for you to discover.
  * Very clean, portable and Object-Oriented pure-Perl API with no hidden
    magic and no requirements besides Perl 5.18.0 (versions as old as 5.10.1
    can be used too, but may require additional CPAN modules to be installed)
  * Full stack HTTP and WebSocket client/server implementation with IPv6, TLS,
    SNI, IDNA, HTTP/SOCKS5 proxy, Comet (long polling), keep-alive, connection
    pooling, timeout, cookie, multipart, and gzip compression support.
  * Built-in non-blocking I/O web server, supporting multiple event loops as
    well as optional preforking and hot deployment, perfect for embedding.
  * Automatic CGI and [PSGI](http://plackperl.org) detection.
  * JSON and HTML/XML parser with CSS selector support.
  * Fresh code based upon years of experience developing
    [Catalyst](http://www.catalystframework.org).

## Installation

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

    $ curl -L cpanmin.us | perl - -n Mojolicious

  And if you already have `cpanm` installed with a secure toolchain.

    $ cpanm --mirror https://cpan.metacpan.org --mirror-only --verify -n Mojolicious

  We recommend the use of a [Perlbrew](http://perlbrew.pl) environment.

## Getting Started

  These three lines are a whole web application.

```perl
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

  Use all the latest Perl and HTML features in beautiful single file
  prototypes like this one, and grow them easily into well-structured
  applications.

```perl
use Mojolicious::Lite;
use 5.20.0;
use experimental 'signatures';

# Render template "index.html.ep" from the DATA section
get '/' => {template => 'index'};

# WebSocket service used by the template to extract the title from a web site
websocket '/title' => sub ($c) {
  $c->on(message => sub ($c, $msg) {
    my $title = $c->ua->get($msg)->res->dom->at('title')->text;
    $c->send($title);
  });
};

app->start;
__DATA__

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

## Want to know more?

  Take a look at our excellent [documentation](http://mojolicio.us/perldoc>)!