Let's install Crystal first so we have the language on our machine. Keep in mind that you can also omit --with-llvm
on the installation if you do not plan to do any contributing to the Crystal Lang.
brew update
brew install crystal-lang --with-llvm
If you run in to any errors, it could be because you don't have xcode installed and using its command line tools.
xcode-select --install
xcode-select --switch /Library/Developer/CommandLineTools
Installing the Amber Framework is pretty simple.
brew install amberframework/amber/amber
Or you can tap into the repo.
brew tap amberframework/amber
brew install amberframework/amber/amber
And that is all that is necessary to start using the Ruby like, compiled language, Crystal.
amber new myApp
cd myApp
shards install
amber generate scaffold Music artist:string genre:string year:integer
amber db create migrate
amber watch
By default the db is postgresql, use -d mysql
to use that instead for the db if desired.
Additionally instead of amber watch
which will compile your app to binary and run it and then check for changes and restart your app automatically, you can also do it the manual way by running crystal src/myApp.cr
.