Create New App
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 -vin your terminal window:
$ amber -v
Amber CLI (amberframework.org) - vX.Y.Z
To bootstrap your Amber application, run
amber newwith 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:
-dThis specifies the database driver to use. It defaults to pg, for PostgreSQL.
-tThis specifies the template rendering engine. It defaults to slang, the Slim-inspired templating language.
Change your current directory to
weblog, if that was the path you chose:
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:
Amber looks at the
database_urlkey for the default database connection string.
Amber assumes that your PostgreSQL database will have a
postgresuser account with the correct permissions and no password set for this user. If that isn’t the case, update the
database_urlkey 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:
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.
amber watchcommand watches for any changes in your source files, recompiling automatically. If you don't want this, you can compile and run manually: