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.
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
shard.yml
Open your /my_app/shard.yml in your favorite editor and add the azu dependency
dependencies:
azu:
github: azutoolkit/azu
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
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
Accepts a block and allows you to define Azu configuration
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
Was this helpful?