Quick Start
Last updated
Last updated
This quick start guide will help you get a full stack web application running in just a few minutes by leveraging maze’s code generators.
It will take us just 7 steps. Let’s get started!
If you already have crystal
, maze
, and a database installed, you can skip this step.
crystal
and maze
Instructions for OS X using homebrew and Debian/Ubuntu are below. See full installation instructions here for RedHat & CentOS, ArchLinux & Derivatives, and more complete instructions.
Installing crystal with homebrew
First install crystal and required libraries
Then install maze (from github)
Above are the steps for building from source, the dependencies are specific to Ubuntu/Debian. See full installation instructions for other Linux Distributions.
Maze works with postgresql
(default), mysql
, or sqlite
.
If you don’t already have one of these installed, please follow the guides provided by each database maintainer:
On OS X any of the databases can be installed with brew install [database]
With all dependencies successfully installed, we can generate a new application with maze new
After the code for the new application is generated, we will cd
into the new directory and execute a shards install
.
The shards install command may take a little while - it has to download all shard dependencies.
The default setup will use a postgresql database, use -d mysql
or -d sqlite
for mysql and sqlite, respectively.
With the skeleton application generated, we can generate our first RESTful resource.
The maze generate scaffold
command will help us do this.
g
is shorthand for generate
Generating the application and the scaffolded resource provides the configuration and migration files needed to setup our database.
maze db
will help us do this.
This will create a new database and run the migration to create a pets
table with the specified columns.
We can use maze watch
to both build the binary application and start the server. Additionally, maze watch
will detect code changes then recompile and restart the application automatically.
Open any browser and goto http://localhost:3000 You should see a home page load and “Pets” in the nav bar. If you click on the “Pets” link, you should be able to perform all 7 RESTful actions for the “pets” resource.
You can use these commands to create new awesome applications :-)
Here is a demo and the source code is available on Github.