So you want to get started with Hanami? Awesome! I’m hoping I can help you with that. I’ve written about why I think Hanami is important; now I want to show you how to build web applications using it. This article is meant to help you setup Hanami.
Before I show you all the neat things Hanami provides, I want to make sure you have everything you need to get started with Hanami. In the event this is your first experience with Ruby, I have some tips on how to install Ruby.
1. Setup Hanami
Hanami is available as a Ruby gem. If you’re unfamiliar with gems, they are Ruby packages available through RubyGems. Having Ruby installed, you already have the tools necessary to install a Ruby gem.
From your terminal, run the following command:
gem install hanami
Once the install completes, you will see a message telling you Hanami installed successfully.
2. Generating A Hanami Application
Now that you have Hanami installed, it’s time to create your first Hanami application. With the Hanami gem installed you have access to Hanami’s command line interface (CLI). Now, run the following command from the terminal:
hanami new blog
This command will bootstrap a new Hanami application in a directory called blog. If you haven’t guessed, these tutorials will guide you through creating a blog. Now, go into the newly created directory.
3. Starting The Application
Finally, it’s time to boot up the application. Hanami, like all good Ruby frameworks, utilizes Rack. Now, use this command to spin up your Hanami application:
At this point, if everything went according to plan you should be able to visit http://localhost:2300 and see the following screen:
Congrats! At this point, you’ve setup Hanami and are ready to start coding.
I’m going to help you with that! In fact, the next lesson covers how to build the first part of the blog.
In the meantime, you have a homework assignment. Open up the newly created app in your favorite editor and take a look around. Things might look a little different than other web frameworks.
Finally, make sure you use the form below to be the first to get the next lesson.
- A Full Stack Ruby Web Framework – Learn Hanami #0
- Setup Hanami – Learn Hanami #1
Interested in More?
I'm an open book!
Drop me your email 👇🏻 and I'll share posts like this with you as I write them.