Productivity. Performance. Happiness.
Amber makes building web applications fast, simple, and enjoyable - with fewer bugs and blazing fast performance.
Amber is a web application framework written in Crystal inspired by Kemal, Rails, Phoenix and other popular application frameworks.
The purpose of Amber is not to create yet another framework, but to take advantage of the beautiful Crystal language capabilities and provide engineers and the Crystal community with an efficient, cohesive, well maintained web framework that embraces the language philosophies, conventions, and guidelines.
Amber borrows concepts that have already been battle tested and successful, and embraces new concepts through team and community collaboration and analysis, which also aligns with Crystal's philosophy.
Documentation https://docs.amberframework.org
Latest Results 968,824.35 requests per second: 32 cores at 2.7Ghz
ubuntu@ip-172-31-0-70:~/bench⟫ wrk -d 60 -t 20 -c 1015 http://localhost:3000
Running 1m test @ http://localhost:3000
20 threads and 1015 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.86ms 2.88ms 56.61ms 87.54%
Req/Sec 48.73k 6.01k 88.40k 68.28%
58225168 requests in 1.00m, 4.01GB read
Requests/sec: 968824.35
Transfer/sec: 68.37MB
Disclaimer: We share these benchmark results with the understanding they may vary depending on configuration and environment settings. By no means are we making any comparison claims in regards to other web application frameworks.
Ensure you have the necessary dependencies:
git
: Use your platform specific package manager to installgit
crystal
: Follow the instructions to getcrystal
on this page: https://crystal-lang.org/docs/installation/index.html
These are necessary to compile the CLI:
- apt-get install build-essential libreadline-dev libsqlite3-dev libpq-dev libmysqlclient-dev libssl-dev`
Once you have these dependencies, you can build amber
from source:
$ git clone git@github.com:amberframework/amber.git
$ cd amber
$ make
$ make install
- Install the CLI from AUR package. Dependencies are automatically installed.
yaourt -S amber
You should now be able to run amber
in the command line.
Best way to get amber
on Mac OS X is via Homebrew:
$ brew install amberframework/amber/amber
Refer to this link if you don't have homebrew installed.
$ amber --help
Amber - Command Line Interface
The `amber new` command creates a new Amber application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
`amber new` runs in the .amber.yml configuration file in your project
root directory
Note that the arguments specified in the .amber.yml file does not affect the
defaults values shown above in this help message.
Usage:
amber new [app_name] -d [pg | mysql | sqlite] -t [slang | ecr] -m [granite, crecto] --deps
Subcommands:
d alias for deploy
database # Performs database maintenance tasks
db alias for database
deploy # Provisions server and deploys project.
e alias for encrypt
encrypt # Encrypts environment YAML file. [env | -e --editor | --noedit]
exec # Executes Crystal code within the application scope
g alias for generate
generate # Generate Amber classes
n alias for new
new # Generates a new Amber project
routes # Prints all defined application routes
w alias for watch
watch # Starts amber development server and rebuilds on file changes
x alias for exec
Options:
-d, --database # Preconfigure for selected database. Options: pg | mysql | sqlite
(default: pg)
-m, --model # Preconfigure for selected model. Options: granite | crecto
(default: granite)
-t, --template # Preconfigure for selected template engine. Options: slang | ecr
(default: slang)
-h, --help # Describe available commands and usages
-v, --version # Prints Amber version
Example:
amber new ~/Code/Projects/weblog
This generates a skeletal Amber installation in ~/Code/Projects/weblog.
amber new [app_name] -d [pg | mysql | sqlite] -t [slang | ecr] -m [granite, crecto] --deps
cd [your_app]
options: -d
defaults to pg. -t
defaults to slang. -m
defaults to granite
.
--deps
will run crystal deps
for you.
This will generate a traditional web application:
- /config - Application and HTTP::Handler config's goes here. The database.yml and routes.cr are here.
- /lib - Shards are installed here.
- /public - Default location for HTML/CSS/js files. The static handler points to this directory.
- /spec - All crystal specs go here.
- /src - All source code goes here.
Generate scaffolding for a resource:
amber generate scaffold Post name:string body:text draft:bool
This will generate scaffolding for Post:
- src/controllers/post_controller.cr
- src/models/post.cr
- src/views/post/*
- db/migrations/[datetimestamp]_create_post.sql
- spec/controllers/post_controller_spec.cr
- spec/models/post_spec.cr
- appends route to config/routes.cr
- appends navigation to src/layouts/_nav.slang
To test the generated app locally:
- Create and migrate the database:
amber db create migrate
. You should see output likeMigrating db, current version: 0, target: [datetimestamp]OK [datetimestamp]_create_shop.sql
- Run the specs:
crystal spec
- Start your app:
amber watch
- Then visit
http://0.0.0.0:3000/
Note: The amber watch
command is based on Sentry to watch for any changes in your source files, recompiling automatically.
If you don't want to use Sentry, you can compile and run manually:
- Build the app
crystal build --release src/[your_app].cr
- Run with
./[your_app]
- Visit
http://0.0.0.0:3000/
Questions or suggestions? Join our IRC channel #amber at chat.freenode.net
or ask on our Gitter room.
It's all about the community. Software development is a team sport!
It's not enough to be brilliant when you're alone in your programming lair. You are not going to change the world or delight millions of users by hiding and preparing your secret invention. We need to work with other members, we need to share our visions, divide the labor, learn from others, we need to be a team.
HUMILITY We are not the center of the universe. You're neither omniscient nor infallible. You are open to self-improvement.
RESPECT You genuinely care about others you work with. You treat them as human beings and appreciate their abilities and accomplishments.
TRUST You believe others are competent and will do the right thing, and you are OK with letting them drive when appropriate.
We have adopted the Contributor Covenant to be our CODE OF CONDUCT guidelines for Amber.
[![Amber Framework](https://img.shields.io/badge/using-amber%20framework-orange.svg)](Your project url)
Contributing to Amber can be a rewarding way to learn, teach, and build experience in just about any skill you can imagine. You don’t have to become a lifelong contributor to enjoy participating in Amber.
Amber is a community effort and we want You to be part of it. Join Amber Community!
- Fork it (https://github.com/amberframework/amber/fork)
- Create your feature branch (git checkout -b my-new-feature)
- Write and execute specs (crystal spec)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- Dru Jensen drujensen
- Elias Perez eliasjpr
- Isaac Sloan elorest
- Faustino Aguilar faustinoaq
- Nick Franken fridgerator
- Mark Siemers marksiemers
- Robert Carpenter robacarp
See more Amber contributors
This project is licensed under the MIT License - see the LICENSE file for details
- Inspired by Kemal, Rails, Phoenix, Hanami