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
  • Bootstrap an Application
  • Creating the database
  1. Guides

Create New App

PreviousInstallationNextDirectory Structure

Last updated 2 years ago

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

At this point, we should have Crystal and Amber installed. We should also have PostgreSQL and NodeJS installed to build a default application.

To verify you have Amber installed, run the command amber -v in your terminal window:

$ amber -v
Amber CLI (amberframework.org) - vX.Y.Z

Bootstrap an Application

To bootstrap your Amber application, run amber new with an absolute or relative directory path to the application directory it should create. Assuming that the name of your application is "weblog", let's run:

$ amber new weblog

Additionally, the following options may be passed to the above command:

  • -d This specifies the database driver to use. It defaults to pg, for PostgreSQL.

  • -t This specifies the template rendering engine. It defaults to slang, the Slim-inspired templating language.

Amber generates the along with files necessary for the application.

Change your current directory to weblog, if that was the path you chose:

cd weblog

Creating the database

Amber makes it easy to interact with your database. Amber supports Postgres, MySql, and Sqlite.

Edit the database setting for your current environment by editing the file:

{project_name}/config/environments/{current_environment}.yml

Amber looks at the database_url key for the default database connection string.

Amber assumes that your PostgreSQL database will have a postgres user account with the correct permissions and no password set for this user. If that isn’t the case, update the database_url key with the correct database credentials for your environment.

With your database credentials ready, run the following command in your terminal window:

amber db create

This creates your application's Postgres database. It should output:

Created database weblog_development

And finally, we’ll start the Amber server:

amber watch

If your screen looks like the image above, congratulations!

Locally, the application is running in a Crystal process. To stop it, we hit ctrl-c once, just as we would terminate the program normally.

The amber watch command watches for any changes in your source files, recompiling automatically. If you don't want this, you can compile and run manually:

  1. Build the app shards build -v

  2. Run with ./[your_app]

By default Amber accepts requests on port 3000. If we point our favorite web browser at , we should see the Amber Framework welcome page.

Oh, yeah!

You now have a working Amber application. If you don’t see the page above, try accessing it via .

Visit

Installation Guide
directory structure
http://localhost:3000
http://127.0.0.1:3000
http://127.0.0.1:3000