SV = RV(0x9404404) at 0x94043f8 REFCNT = 1 FLAGS = (PADMY,ROK) RV = 0x94631b0 SV = PVHV(0x94ef238) at 0x94631b0 REFCNT = 1 FLAGS = (OBJECT,OVERLOAD,SHAREKEYS) STASH = 0x8deed28 "Mojo::ByteStream" ARRAY = 0x9497b60 (0:7, 1:1) hash quality = 100.0% KEYS = 1 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "bytestream" HASH = 0x398030c9 SV = PV(0x9474f70) at 0x94632a0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x9501840 "\n

NAME

\n\n

Mojolicious - The Web In A Box!

\n\n

SYNOPSIS

\n\n
    # Mojolicious application\n    package MyApp;\n\n    use base 'Mojolicious';\n\n    sub startup {\n        my $self = shift;\n\n        # Routes\n        my $r = $self->routes;\n\n        # Default route\n        $r->route('/:controller/:action/:id')->to('foo#welcome');\n    }\n\n    # Mojolicious controller\n    package MyApp::Foo;\n\n    use base 'Mojolicious::Controller';\n\n    # Say hello\n    sub welcome {\n        my $self = shift;\n        $self->render(text => 'Hi there!');\n    }\n\n    # Say goodbye from a template (foo/bye.html.ep)\n    sub bye { shift->render }
\n\n

DESCRIPTION

\n\n

Back in the early days of the web there was this wonderful Perl library called CGI, many people only learned Perl because of it. 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.

\n\n

Features

\n\n\n\n

Duct Tape For The HTML5 Web

\n\n

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

\n\n
    use Mojolicious::Lite;\n\n    get '/hello' => sub { shift->render(text => 'Hello World!') };\n\n    get '/time' => 'clock';\n\n    websocket '/echo' => sub {\n        my $self = shift;\n        $self->on_message(\n            sub {\n                my ($self, $message) = @_;\n                $self->send_message("echo: $message");\n            }\n        );\n    };\n\n    get '/title' => sub {\n        my $self = shift;\n        my $url  = $self->param('url');\n        $self->render(text =>\n              $self->client->get($url)->res->dom->at('title')->text);\n    };\n\n    post '/:offset' => sub {\n        my $self   = shift;\n        my $offset = $self->param('offset') || 23;\n        $self->render(json => {list => [0 .. $offset]});\n    };\n\n    app->start;\n    __DATA__\n\n    @@ clock.html.ep\n    % my ($second, $minute, $hour) = (localtime(time))[0, 1, 2];\n    <%= link_to clock => begin %>\n        The time is <%= $hour %>:<%= $minute %>:<%= $second %>.\n    <% end %>
\n\n

Single file prototypes can easily grow into well structured applications.

\n\n

Have Some Cake

\n\n

Loosely coupled building blocks, use what you like and just ignore the rest.

\n\n
    .---------------------------------------------------------------.\n    |                                                               |\n    |                .----------------------------------------------'\n    |                | .--------------------------------------------.\n    |   Application  | |              Mojolicious::Lite             |\n    |                | '--------------------------------------------'\n    |                | .--------------------------------------------.\n    |                | |                 Mojolicious                |\n    '----------------' '--------------------------------------------'\n    .---------------------------------------------------------------.\n    |                             Mojo                              |\n    '---------------------------------------------------------------'\n    .-------. .-----------. .--------. .------------. .-------------.\n    |  CGI  | |  FastCGI  | |  PSGI  | |  HTTP 1.1  | |  WebSocket  |\n    '-------' '-----------' '--------' '------------' '-------------'
\n\n

Highlights

\n\n

These are some of the most important building blocks of Mojolicious.

\n\n
\n
Mojolicious::Lite
\n\n
\n

Micro Web Framework built on top of Mojolicious for prototypes and small applications.

\n\n
Mojo::Client
\n\n
\n

Full featured async io HTTP 1.1 and WebSocket client.

\n\n
Mojo::DOM
\n\n
\n

Very fun and minimalistic XML/HTML5 DOM parser with CSS3 selector support.

\n\n
Mojo::JSON
\n\n
\n

Minimalistic JSON implementation that just works.

\n\n
Mojo::Server::Daemon
\n\n
\n

Highly portable async io HTTP 1.1 and WebSocket server, perfect for development and testing.

\n\n
Mojo::Server::Hypnotoad
\n\n
\n

Full featured UNIX optimized preforking async io HTTP 1.1 and WebSocket server with support for zero downtime software upgrades (hot deployment).

\n\n
Mojo::Server::CGI, Mojo::Server::FastCGI, Mojo::Server::PSGI
\n\n
\n

Transparent CGI, FastCGI and PSGI support out of the box.

\n\n
Mojo::Template
\n\n
\n

Very perlish and minimalistic template system.

\n\n
Mojo::ByteStream
\n\n
\n

Countless portable and very convenient bytestream manipulation methods.

\n\n
Mojolicious::Commands
\n\n
\n

Pluggable command line system and the backbone of the mojo script.

\n\n
Test::Mojo
\n\n
\n

Test driven development toolkit for web applications.

\n\n
ojo
\n\n
\n

Fun oneliners using everything above.

\n
\n
\n\n

For more documentation see Mojolicious::Guides and the tutorial in Mojolicious::Lite!

\n\n

ATTRIBUTES

\n\n

Mojolicious inherits all attributes from Mojo and implements the following new ones.

\n\n

controller_class

\n\n
    my $class = $app->controller_class;\n    $app      = $app->controller_class('Mojolicious::Controller');
\n\n

Class to be used for the default controller, defaults to Mojolicious::Controller.

\n\n

mode

\n\n
    my $mode = $app->mode;\n    $app     = $app->mode('production');
\n\n

The operating mode for your application. It defaults to the value of the environment variable MOJO_MODE or development. Mojo will name the log file after the current mode and modes other than development will result in limited log output.

\n\n

If you want to add per mode logic to your application, you can add a sub to your application named $mode_mode.

\n\n
    sub development_mode {\n        my $self = shift;\n    }\n\n    sub production_mode {\n        my $self = shift;\n    }
\n\n

plugins

\n\n
    my $plugins = $app->plugins;\n    $app        = $app->plugins(Mojolicious::Plugins->new);
\n\n

The plugin loader, by default a Mojolicious::Plugins object. You can usually leave this alone, see Mojolicious::Plugin if you want to write a plugin.

\n\n

renderer

\n\n
    my $renderer = $app->renderer;\n    $app         = $app->renderer(Mojolicious::Renderer->new);
\n\n

Used in your application to render content, by default a Mojolicious::Renderer object. The two main renderer plugins Mojolicious::Plugin::EpRenderer and Mojolicious::Plugin::EplRenderer contain more specific information.

\n\n

routes

\n\n
    my $routes = $app->routes;\n    $app       = $app->routes(Mojolicious::Routes->new);
\n\n

The routes dispatcher, by default a Mojolicious::Routes object. You use this in your startup method to define the url endpoints for your application.

\n\n
    sub startup {\n        my $self = shift;\n\n        my $r = $self->routes;\n        $r->route('/:controller/:action')->to('test#welcome');\n    }
\n\n

secret

\n\n
    my $secret = $app->secret;\n    $app       = $app->secret('passw0rd');
\n\n

A secret passphrase used for signed cookies and the like, defaults to the application name which is not very secure, so you should change it!!! As long as you are using the unsecure default there will be debug messages in the log file reminding you to change your passphrase.

\n\n

session

\n\n
    my $session = $app->session;\n    $app        = $app->session(Mojolicious::Session->new);
\n\n

Simple singed cookie based sessions, by default a Mojolicious::Session object.

\n\n

static

\n\n
    my $static = $app->static;\n    $app       = $app->static(Mojolicious::Static->new);
\n\n

For serving static assets from your public directory, by default a Mojolicious::Static object.

\n\n

types

\n\n
    my $types = $app->types;\n    $app      = $app->types(Mojolicious::Types->new);
\n\n

Responsible for tracking the types of content you want to serve in your application, by default a Mojolicious::Types object. You can easily register new types.

\n\n
    $app->types->type(vti => 'help/vampire');
\n\n

METHODS

\n\n

Mojolicious inherits all methods from Mojo and implements the following new ones.

\n\n

new

\n\n
    my $app = Mojolicious->new;
\n\n

Construct a new Mojolicious application. Will automatically detect your home directory and set up logging based on your current operating mode. Also sets up the renderer, static dispatcher and a default set of plugins.

\n\n

defaults

\n\n
    my $defaults = $app->defaults;\n    my $foo      = $app->defaults('foo');\n    $app         = $app->defaults({foo => 'bar'});\n    $app         = $app->defaults(foo => 'bar');
\n\n

Default values for the stash. Note that this method is EXPERIMENTAL and might change without warning!

\n\n
    $app->defaults->{foo} = 'bar';\n    my $foo = $app->defaults->{foo};\n    delete $app->defaults->{foo};
\n\n

dispatch

\n\n
    $app->dispatch($c);
\n\n

The heart of every Mojolicious application, calls the static and routes dispatchers for every request and passes them a Mojolicious::Controller object.

\n\n

handler

\n\n
    $tx = $app->handler($tx);
\n\n

Sets up the default controller and calls process for every request.

\n\n

helper

\n\n
    $app->helper(foo => sub { ... });
\n\n

Add a new helper that will be available as a method of the controller object and the application object, as well as a function in ep templates. Note that this method is EXPERIMENTAL and might change without warning!

\n\n
    # Helper\n    $app->helper(add => sub { $_[1] + $_[2] });\n\n    # Controller/Application\n    my $result = $self->add(2, 3);\n\n    # Template\n    <%= add 2, 3 %>
\n\n

hook

\n\n
    $app->hook(after_dispatch => sub { ... });
\n\n

Add hooks to named events. Note that this method is EXPERIMENTAL and might change without warning!

\n\n

The following events are available and run in the listed order.

\n\n
\n
after_build_tx
\n\n
\n

Triggered right after the transaction is built and before the HTTP request gets parsed. One use case would be upload progress bars. (Passed the transaction and application instances)

\n\n
    $app->hook(before_request => sub {\n        my ($tx, $app) = @_;\n    });
\n\n
before_dispatch
\n\n
\n

Triggered right before the static and routes dispatchers start their work. (Passed the default controller instance)

\n\n
    $app->hook(before_dispatch => sub {\n        my $self = shift;\n    });
\n\n
after_static_dispatch
\n\n
\n

Triggered after the static dispatcher determined if a static file should be served and before the routes dispatcher starts its work, the callbacks of this hook run in reverse order. (Passed the default controller instance)

\n\n
    $app->hook(after_static_dispatch => sub {\n        my $self = shift;\n    });
\n\n
after_dispatch
\n\n
\n

Triggered after the static and routes dispatchers are finished and a response has been rendered, the callbacks of this hook run in reverse order. (Passed the current controller instance)

\n\n
    $app->hook(after_dispatch => sub {\n        my $self = shift;\n    });
\n
\n
\n\n

plugin

\n\n
    $app->plugin('something');\n    $app->plugin('something', foo => 23);\n    $app->plugin('something', {foo => 23});\n    $app->plugin('Foo::Bar');\n    $app->plugin('Foo::Bar', foo => 23);\n    $app->plugin('Foo::Bar', {foo => 23});
\n\n

Load a plugin. Note that this method is EXPERIMENTAL and might change without warning!

\n\n

process

\n\n
    $app->process($c);
\n\n

This method can be overloaded to do logic on a per request basis, by default just calls dispatch and passes it a Mojolicious::Controller object. Generally you will use a plugin or controller instead of this, consider it the sledgehammer in your toolbox.

\n\n
    sub process {\n        my ($self, $c) = @_;\n        $self->dispatch($c);\n    }
\n\n

start

\n\n
    Mojolicious->start;\n    Mojolicious->start('daemon');
\n\n

Start the Mojolicious::Commands command line interface for your application.

\n\n

startup

\n\n
    $app->startup;
\n\n

This is your main hook into the application, it will be called at application startup.

\n\n
    sub startup {\n        my $self = shift;\n    }
\n\n

SUPPORT

\n\n

Web

\n\n
    http://mojolicious.org
\n\n

IRC

\n\n
    #mojo on irc.perl.org
\n\n

Mailing-List

\n\n
    http://groups.google.com/group/mojolicious
\n\n

DEVELOPMENT

\n\n

Repository

\n\n
    http://github.com/kraih/mojo
\n\n

CODE NAMES

\n\n

Every major release of Mojolicious has a code name, these are the ones that have been used in the past.

\n\n

1.0, Snowflake (u2744)

\n\n

0.999930, Hot Beverage (u2615)

\n\n

0.999927, Comet (u2604)

\n\n

0.999920, Snowman (u2603)

\n\n

AUTHOR

\n\n

Sebastian Riedel, sri@cpan.org.

\n\n

CORE DEVELOPERS EMERITUS

\n\n

Retired members of the core team, we thank you dearly for your service.

\n\n
\n

Viacheslav Tykhanovskyi, vti@cpan.org.

\n
\n\n

CREDITS

\n\n

In alphabetical order.

\n\n
\n

Adam Kennedy

\n\n

Adriano Ferreira

\n\n

Alex Salimon

\n\n

Alexey Likhatskiy

\n\n

Anatoly Sharifulin

\n\n

Andre Vieth

\n\n

Andrew Fresh

\n\n

Andreas Koenig

\n\n

Andy Grundman

\n\n

Aristotle Pagaltzis

\n\n

Ashley Dev

\n\n

Ask Bjoern Hansen

\n\n

Audrey Tang

\n\n

Breno G. de Oliveira

\n\n

Burak Gursoy

\n\n

Ch Lamprecht

\n\n

Charlie Brady

\n\n

Chas. J. Owens IV

\n\n

Christian Hansen

\n\n

Curt Tilmes

\n\n

Danijel Tasov

\n\n

David Davis

\n\n

Dmitriy Shalashov

\n\n

Dmitry Konstantinov

\n\n

Eugene Toropov

\n\n

Gisle Aas

\n\n

Glen Hinkle

\n\n

Graham Barr

\n\n

Hideki Yamamura

\n\n

James Duncan

\n\n

Jan Jona Javorsek

\n\n

Jaroslav Muhin

\n\n

Jesse Vincent

\n\n

John Kingsley

\n\n

Jonathan Yu

\n\n

Kazuhiro Shibuya

\n\n

Kevin Old

\n\n

Lars Balker Rasmussen

\n\n

Leon Brocard

\n\n

Maik Fischer

\n\n

Marcus Ramberg

\n\n

Mark Stosberg

\n\n

Matthew Lineen

\n\n

Maksym Komar

\n\n

Maxim Vuets

\n\n

Mirko Westermeier

\n\n

Mons Anderson

\n\n

Oleg Zhelo

\n\n

Pascal Gaudette

\n\n

Paul Tomlin

\n\n

Pedro Melo

\n\n

Peter Edwards

\n\n

Pierre-Yves Ritschard

\n\n

Quentin Carbonneaux

\n\n

Rafal Pocztarski

\n\n

Randal Schwartz

\n\n

Robert Hicks

\n\n

Ryan Jendoubi

\n\n

Sascha Kiefer

\n\n

Sergey Zasenko

\n\n

Simon Bertrang

\n\n

Shu Cho

\n\n

Stanis Trendelenburg

\n\n

Tatsuhiko Miyagawa

\n\n

The Perl Foundation

\n\n

Tomas Znamenacek

\n\n

Ulrich Habel

\n\n

Ulrich Kautz

\n\n

Uwe Voelker

\n\n

Yaroslav Korshak

\n\n

Yuki Kimoto

\n\n

Zak B. Elep

\n
\n\n

COPYRIGHT AND LICENSE

\n\n

Copyright (C) 2008-2010, Sebastian Riedel.

\n\n

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

\n"\0 CUR = 21522 LEN = 21524