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
Mojolicious - The Web In A Box!
\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
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\n\nPowerful out of the box with RESTful routes, plugins, Perl-ish templates, session management, signed cookies, testing framework, static file server, I18N, first class unicode support and much more for you to discover.
\n
Web development for humans, making hard things possible and everything fun.
\n\nuse 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\nLoosely 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
These are some of the most important building blocks of Mojolicious.
\n\nMicro Web Framework built on top of Mojolicious for prototypes and small applications.
\n\nFull featured async io HTTP 1.1 and WebSocket client.
\n\nVery fun and minimalistic XML/HTML5 DOM parser with CSS3 selector support.
\n\nMinimalistic JSON implementation that just works.
\n\nHighly portable async io HTTP 1.1 and WebSocket server, perfect for development and testing.
\n\nFull featured UNIX optimized preforking async io HTTP 1.1 and WebSocket server with support for zero downtime software upgrades (hot deployment).
\n\nTransparent CGI, FastCGI and PSGI support out of the box.
\n\nVery perlish and minimalistic template system.
\n\nCountless portable and very convenient bytestream manipulation methods.
\n\nPluggable command line system and the backbone of the mojo
script.
Test driven development toolkit for web applications.
\n\nFun oneliners using everything above.
\nFor more documentation see Mojolicious::Guides and the tutorial in Mojolicious::Lite!
\n\nMojolicious inherits all attributes from Mojo and implements the following new ones.
\n\ncontroller_class
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\nmode
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.
If you want to add per mode logic to your application, you can add a sub to your application named $mode_mode
.
sub development_mode {\n my $self = shift;\n }\n\n sub production_mode {\n my $self = shift;\n }\n\n
plugins
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\nrenderer
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\nroutes
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\nsub startup {\n my $self = shift;\n\n my $r = $self->routes;\n $r->route('/:controller/:action')->to('test#welcome');\n }\n\n
secret
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\nsession
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\nstatic
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.
types
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
Mojolicious inherits all methods from Mojo and implements the following new ones.
\n\nnew
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\ndefaults
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
$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\nhandler
$tx = $app->handler($tx);\n\n
Sets up the default controller and calls process for every request.
\n\nhelper
$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!
# 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
$app->hook(after_dispatch => sub { ... });\n\n
Add hooks to named events. Note that this method is EXPERIMENTAL and might change without warning!
\n\nThe following events are available and run in the listed order.
\n\nTriggered 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
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
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
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
plugin
$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\nprocess
$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\nsub process {\n my ($self, $c) = @_;\n $self->dispatch($c);\n }\n\n
start
Mojolicious->start;\n Mojolicious->start('daemon');\n\n
Start the Mojolicious::Commands command line interface for your application.
\n\nstartup
$app->startup;\n\n
This is your main hook into the application, it will be called at application startup.
\n\nsub startup {\n my $self = shift;\n }\n\n
http://mojolicious.org\n\n
#mojo on irc.perl.org\n\n
http://groups.google.com/group/mojolicious\n\n
http://github.com/kraih/mojo\n\n
Every major release of Mojolicious has a code name, these are the ones that have been used in the past.
\n\n1.0, Snowflake
(u2744)
0.999930, Hot Beverage
(u2615)
0.999927, Comet
(u2604)
0.999920, Snowman
(u2603)
Sebastian Riedel, sri@cpan.org
.
Retired members of the core team, we thank you dearly for your service.
\n\n\n\n\nViacheslav Tykhanovskyi,
\nvti@cpan.org
.
In alphabetical order.
\n\n\n\n\nAdam Kennedy
\n\nAdriano Ferreira
\n\nAlex Salimon
\n\nAlexey Likhatskiy
\n\nAnatoly Sharifulin
\n\nAndre Vieth
\n\nAndrew Fresh
\n\nAndreas Koenig
\n\nAndy Grundman
\n\nAristotle Pagaltzis
\n\nAshley Dev
\n\nAsk Bjoern Hansen
\n\nAudrey Tang
\n\nBreno G. de Oliveira
\n\nBurak Gursoy
\n\nCh Lamprecht
\n\nCharlie Brady
\n\nChas. J. Owens IV
\n\nChristian Hansen
\n\nCurt Tilmes
\n\nDanijel Tasov
\n\nDavid Davis
\n\nDmitriy Shalashov
\n\nDmitry Konstantinov
\n\nEugene Toropov
\n\nGisle Aas
\n\nGlen Hinkle
\n\nGraham Barr
\n\nHideki Yamamura
\n\nJames Duncan
\n\nJan Jona Javorsek
\n\nJaroslav Muhin
\n\nJesse Vincent
\n\nJohn Kingsley
\n\nJonathan Yu
\n\nKazuhiro Shibuya
\n\nKevin Old
\n\nLars Balker Rasmussen
\n\nLeon Brocard
\n\nMaik Fischer
\n\nMarcus Ramberg
\n\nMark Stosberg
\n\nMatthew Lineen
\n\nMaksym Komar
\n\nMaxim Vuets
\n\nMirko Westermeier
\n\nMons Anderson
\n\nOleg Zhelo
\n\nPascal Gaudette
\n\nPaul Tomlin
\n\nPedro Melo
\n\nPeter Edwards
\n\nPierre-Yves Ritschard
\n\nQuentin Carbonneaux
\n\nRafal Pocztarski
\n\nRandal Schwartz
\n\nRobert Hicks
\n\nRyan Jendoubi
\n\nSascha Kiefer
\n\nSergey Zasenko
\n\nSimon Bertrang
\n\nShu Cho
\n\nStanis Trendelenburg
\n\nTatsuhiko Miyagawa
\n\nThe Perl Foundation
\n\nTomas Znamenacek
\n\nUlrich Habel
\n\nUlrich Kautz
\n\nUwe Voelker
\n\nYaroslav Korshak
\n\nYuki Kimoto
\n\nZak B. Elep
\n
Copyright (C) 2008-2010, Sebastian Riedel.
\n\nThis 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