Amber Framework
WebsiteBlogGithubDiscord
  • Introduction
  • Getting Started
  • Guides
    • Overview
    • Installation
    • Create New App
    • Directory Structure
    • Configuration
    • Docker
    • Controllers
      • Sessions
      • Request & Response Objects
      • Halt!
      • Respond With
      • Params
      • Cookies
      • Filters
      • Flash
      • Redirection
      • CSRF
    • Views
      • Basic View Helpers
      • Form Builder
    • Models
      • Granite
        • Granite's README
        • Migrations
        • Validations
        • Callbacks
        • Associations
        • Querying
        • Bulk Insertions
      • Jennifer
        • Jennifer Docs
        • Migrations
        • Models
    • Routing
      • Pipelines
      • Routes
    • Websockets
      • Channels
      • Sockets
      • JavaScript Client
    • Mailers
    • Testing
      • System Tests
  • Deployment
    • Manual Deploy
    • Digital Ocean
    • Heroku
    • Dokku
  • CLI
    • New
    • Recipes
    • Plugins
    • Generate
    • Database
    • Watch
    • Routes
    • Exec
    • Encrypt
  • Examples
    • Amber Auth
    • Crystal Debug
    • Minimal Configuration
  • Cookbook
    • From Scratch
    • Hello World
    • CORS
    • File Download
    • File Upload
    • Cookies
    • Authenticate
    • JSON API
    • JSON Mapping
    • WebSocket Chat
  • Troubleshooting
  • In Production
  • Contributing
  • Code of Conduct
  • HAVE A QUESTION?
    • Join the Discord
    • Follow on Twitter
    • Submit an issue
Powered by GitBook
On this page
  • Quick Start
  • 1. Install dependencies
  • 1.1 Install crystal and amber
  • 1.2 Install a database
  • 2. Generate a new Amber application
  • 3. Generate a resource
  • 4. Create and migrate the database
  • 5. Build the application and run the server
  • 6. Use your brand new web application!
  • 7. Deploy your web application
  • List of Commands
  • Demo

Getting Started

PreviousIntroductionNextGuides

Last updated 1 year ago

Quick Start

This quick start guide will help you get a full stack web application running in just a few minutes by leveraging amber’s code generators.

It will take us just 7 steps. Let’s get started!

Let’s get started!

1. Install dependencies

1.1 Install crystal and amber

macOS

Installing Amber with these package managers also installs Crystal.

  • Homebrew

    brew tap amberframework/amber
    brew install amber
  • MacPorts

    sudo port selfupdate
    sudo port install amber

Ubuntu or Debian

curl -fsSL https://crystal-lang.org/install.sh | sudo bash

Then install Amber (from source)

NOTE: At the time of this writing, v1.4.1 is the current stable release, but you should use the most recent tag in place of that.

sudo apt-get install libreadline-dev libsqlite3-dev libpq-dev libmysqlclient-dev libssl-dev libyaml-dev libpcre3-dev libevent-dev
git clone https://github.com/amberframework/amber.git
cd amber
git checkout v1.4.1
shards install
make
sudo make install
brew tap amberframework/amber
brew install amber

1.2 Install a database

Amber 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]

Docker users can opt to use a database container to develop with as well. By default, a new Amber application generates a docker-compose.yml that can be used for this purpose.

2. Generate a new Amber application

With all dependencies successfully installed, we can generate a new application with amber 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.

amber new pet-tracker
cd pet-tracker

3. Generate a resource

With the skeleton application generated, we can generate our first RESTful resource.

The amber generate scaffold command will help us do this.

g is shorthand for generate

amber g scaffold Pet name:string breed:string age:integer

4. Create and migrate the database

Generating the application and the scaffolded resource provides the configuration and migration files needed to set up the database.

amber db will help us do this, as you will see you can chain the db commands together.

amber db create migrate

This will create a new database and run the migration to create a pets table with the specified columns.

5. Build the application and run the server

We can use amber watch to both build the binary application and start the server. Additionally, amber watch will detect code changes then recompile and restart the application automatically.

amber watch

The watch commands will keep observing for file changes within the project and recompiling the application.

6. Use your brand new web application!

7. Deploy your web application

List of Commands

You can use these commands to create new awesome applications :-)

amber new pet-tracker
cd pet-tracker
shards install
amber generate scaffold Pet name:string breed:string age:integer
amber db create migrate
amber watch

Demo

If you already have crystal, amber, and a database installed, you can .

Instructions for OS X using Homebrew or MacPorts and Debian/Ubuntu are below. See full installation instructions for RedHat & CentOS, ArchLinux & Derivatives, and more complete instructions.

First install crystal (from the ):

You can also install Amber with

Above are the steps for building from source, the dependencies are specific to Ubuntu/Debian. See for other Linux Distributions.

Open any browser and goto 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 seven RESTful actions for the “pets” resource.

Here is the Quick Start demo app and the source code is available on .

Quick Start Demo
here
official install documentation
Linuxbrew
full installation instructions
Postgresql Installation Guides
MySQL Installation Guides
Tutorial on installing SQLite
http://localhost:3000
Deployment
Github
Guides
skip this step