Create new app

Learn how to get started with Azu and build applications

Let's get a Azu application up and running as quickly as possible.

Before we begin, please take a minute to read the Installation Guide. By installing any necessary dependencies beforehand, we'll be able to get our application up and running smoothly.

Generate a Crystal App Project

We can run crystal init app my_app from any directory in order to bootstrap our Azu application. Assuming that the name of our application is my_app, let's run the following command:

 crystal init app my_app
    create  /my_app/.gitignore
    create  /my_app/.editorconfig
    create  /my_app/LICENSE
    create  /my_app/README.md
    create  /my_app/.travis.yml
    create  /my_app/shard.yml
    create  /my_app/src/my_app.cr
    create  /my_app/spec/spec_helper.cr
    create  /my_app/spec/my_app_spec.cr
Initialized empty Git repository in /home/eperez/workspaces/my_app/.git/

Add the dependency to your shard.yml

Open your /my_app/shard.yml in your favorite editor and add the azu dependency

dependencies:
  azu:
    github: azutoolkit/azu

Azu is very light, flexible and module, for this reason it does not add front-end dependencies nor database dependencies. We will teach you how you can integrate those later in the guides

Run Shards Install

Now install Azu by running shards install from the terminal

 shards install

Enabling Azu in Your project

Now that you have install Azu, lets enable it in your project. Open /my_app/src/my_app.cr

/my_app/src/my_app.cr
require "azu"

# TODO: Write documentation for `MyApp`
module MyApp
  VERSION = "0.1.0"

  # Include the Azu module
  include Azu
end

With the simple include azu you have unlocked the benefits of Azu for your project.

Available methods

Name

MyApp.configure

MyApp.log

This is the application logger and uses Crystal built in logger by default

MyApp.env

Allows you to work with the application current environment Production, Development, Staging, etc.

MyApp.config

Gets your application configuration for easy access from other parts of the code base

MyApp.start

Starts the HTTP server

Last updated