Introduction to Mojolicious Perl Web Framework

An introduction to web development using Mojolicious, Perl's flagship framework. Learn the basics of installing Mojolicious and creating web applications with Mojollicious.

use Mojolicious::Lite;

get '/' => {text =>'Hello World!'};

app->start;

It works on Windows, Linux and any environment. For those who think "I didn't like CGI", now there is "Mojolicious".

1. Features of Mojolicious

I think there is such a question, "Is Mojolicious only a small website?" In fact, Mojolicious can start from a small website and grow steadily.

Mojolicious

    1. Creating a website easily and quickly
    2. Provides a set of functions required for website creation
    3. Supports large-scale web application development

It has the feature.

Mojolicious provides "a set of features needed to create a website".

    • Template, parameter acquisition, form processing, URL creation
    • Sessions, cookies, WebSockets, asynchronous I / O, authentication
    • SSL, JSON, web server

You can write HTML quickly using the "template function". "Parameters" are also easy to get, and "Sessions" are also supported by default. Since it supports "asynchronous I / O", it can handle even if the load becomes high after the service starts.

Is there a web service you want to create? If you want to create efficient and maintainable web apps, Mojolicious is for you.

2. Introduction to Mojolicious

Let's start by installing Mojolicious. After that, I will actually run Mojolicious.

2.1 Installing Mojolicious

I will explain the procedure to install Mojolicious.

2.2 Let's display "Hello World" in Mojolicious

Let's create the simplest Hello World application with Mojolicious.

use Mojolicious::Lite;

get '/' => sub {
  my $self = shift;

  $self->render(text =>'Hello World');
};

app->start;

See Smallest Web Application for a description and how to execute it.

In the introduction to Mojolicious, I will write articles on the assumption that I have knowledge of "HTML" and "CSS". If you don't know the minimum "HTML" or "CSS" yet, HTML basics and CSS Basics.

2.3 Publication on the Internet

"I want to publish a website as soon as I create it!"

The easiest way is to publish your application using "Sakura Rental Server Standard". If you want to publish it immediately, please see Publish the app on Sakura Rental Server Standard. If you want to move on without publishing it yet, you can read it later.

The joy of running a site I created on the Internet is exceptional. Please give it a try!

Web application basics

I will explain the basics of Web applications using Mojolicious.

Installation

Creating a template

Route

Controller

Drawing templates and JSON

Character code

File upload

Utilities

Tag helper

Session

URL

Plugins

Introducing how to use Mojolicious plugins and modules.

Exam

Deploy

Cooperation with SSL

Web scraping

Performance

hypnotoad prefork server

Non-blocking IO

Others

Release information

Sakura rental server

An article useful for using Mojolicious on Sakura's rental server.

Mojolicious sample

Introducing a sample using Mojolicious.

Mojolicious documentation

The official document of Mojolicious. This document describes all the features of Mojolicious. If you don't know, always refer to this.

Mojolicious related courses

This is a Mojolicious related course.

Web development environment construction

It is a site for building a web development environment on Ubuntu to run Mojolicious in a production environment.

Web application development

Explains how to develop web apps with Perl and Mojolicious.

Associated Information