Mojolicious::Lite - Micro real-time web framework
# Automatically enables "strict", "warnings", "utf8" and Perl 5.10 features use Mojolicious::Lite; # Route with placeholder get '/:foo' => sub { my $c = shift; my $foo = $c->param('foo'); $c->render(text => "Hello from $foo."); }; # Start the Mojolicious command system app->start;
Mojolicious::Lite is a micro real-time web framework built around Mojolicious.
See Mojolicious::Guides::Tutorial for more!
Mojolicious::Lite implements the following functions, which are automatically exported.
my $route = any '/:foo' => sub {...}; my $route = any '/:foo' => sub {...} => 'name'; my $route = any '/:foo' => {foo => 'bar'} => sub {...}; my $route = any '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = any ['GET', 'POST'] => '/:foo' => sub {...}; my $route = any ['GET', 'POST'] => '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "any" in Mojolicious::Routes::Route, matching any of the listed HTTP request methods or all. See also Mojolicious::Guides::Tutorial for many more argument variations.
my $app = app;
Returns the Mojolicious::Lite application object, which is a subclass of Mojolicious.
# Use all the available attributes and methods app->log->level('error'); app->defaults(foo => 'bar');
my $route = del '/:foo' => sub {...}; my $route = del '/:foo' => sub {...} => 'name'; my $route = del '/:foo' => {foo => 'bar'} => sub {...}; my $route = del '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "delete" in Mojolicious::Routes::Route, matching only DELETE requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
DELETE
my $route = get '/:foo' => sub {...}; my $route = get '/:foo' => sub {...} => 'name'; my $route = get '/:foo' => {foo => 'bar'} => sub {...}; my $route = get '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "get" in Mojolicious::Routes::Route, matching only GET requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
GET
group {...};
Start a new route group.
helper foo => sub {...};
Add a new helper with "helper" in Mojolicious.
hook after_dispatch => sub {...};
Share code with "hook" in Mojolicious.
my $route = options '/:foo' => sub {...}; my $route = options '/:foo' => sub {...} => 'name'; my $route = options '/:foo' => {foo => 'bar'} => sub {...}; my $route = options '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "options" in Mojolicious::Routes::Route, matching only OPTIONS requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
OPTIONS
my $route = patch '/:foo' => sub {...}; my $route = patch '/:foo' => sub {...} => 'name'; my $route = patch '/:foo' => {foo => 'bar'} => sub {...}; my $route = patch '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "patch" in Mojolicious::Routes::Route, matching only PATCH requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
PATCH
plugin SomePlugin => {foo => 23};
Load a plugin with "plugin" in Mojolicious.
my $route = post '/:foo' => sub {...}; my $route = post '/:foo' => sub {...} => 'name'; my $route = post '/:foo' => {foo => 'bar'} => sub {...}; my $route = post '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "post" in Mojolicious::Routes::Route, matching only POST requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
POST
my $route = put '/:foo' => sub {...}; my $route = put '/:foo' => sub {...} => 'name'; my $route = put '/:foo' => {foo => 'bar'} => sub {...}; my $route = put '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "put" in Mojolicious::Routes::Route, matching only PUT requests. See also Mojolicious::Guides::Tutorial for many more argument variations.
PUT
my $route = under sub {...}; my $route = under '/:foo' => sub {...}; my $route = under '/:foo' => {foo => 'bar'}; my $route = under '/:foo' => [foo => qr/\w+/]; my $route = under [format => 0];
Generate nested route with "under" in Mojolicious::Routes::Route, to which all following routes are automatically appended. See also Mojolicious::Guides::Tutorial for more argument variations.
my $route = websocket '/:foo' => sub {...}; my $route = websocket '/:foo' => sub {...} => 'name'; my $route = websocket '/:foo' => {foo => 'bar'} => sub {...}; my $route = websocket '/:foo' => [foo => qr/\w+/] => sub {...};
Generate route with "websocket" in Mojolicious::Routes::Route, matching only WebSocket handshakes. See also Mojolicious::Guides::Tutorial for many more argument variations.
Mojolicious::Lite inherits all attributes from Mojolicious.
Mojolicious::Lite inherits all methods from Mojolicious.
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.