Ruby Language Getting started with Hanami How to install Hanami?


  • Step 1: Installing the Hanami gem.
  $ gem install hanami
  • Step 2: Generate a new project setting RSpec as testing framework.

    Open up a command line or terminal. To generate a new hanami application, use hanami new followed by the name of your app and the rspec test param.

 $ hanami new "myapp" --test=rspec 

Obs. By default Hanami sets Minitest as testing framework.

This will create a hanami application called myapp in a myapp directory and install the gem dependencies that are already mentioned in Gemfile using bundle install.

To switch to this directory, use the cd command, which stands for change directory.

$ cd my_app
$ bundle install

The myapp directory has a number of auto-generated files and folders that make up the structure of a Hanami application. Following is a list of files and folders that are created by default:

  • Gemfile defines our Rubygems dependencies (using Bundler).

  • Rakefile describes our Rake tasks.

  • apps contains one or more web applications compatible with Rack. Here we can find the first generated Hanami application called Web. It's the place where we find our controllers, views, routes and templates.

  • config contains configuration files.

  • is for Rack servers.

  • db contains our database schema and migrations.

  • lib contains our business logic and domain model, including entities and repositories.

  • public will contain compiled static assets.

  • spec contains our tests.

  • Important links.

Hanami gem

Hanami official Getting Started