Let’s chat about the new release of Hanami 2.0 Web Framework and what you can use it for. Let's learn how you can start with it, and some examples from an application that is already making use of Hanami in production.
Focused on maintainability, testability, and scaling - Create applications that are systems of well-formed components with clear dependencies. - Anyone work on a really big Rails app? - Let’s dive in on what a Hanami project looks like, and it’s benefits
bundler. Guardfile Supports code reloading in development. README.md The application’s readme document. Rakefile Support for running rake tasks. app/ This is the directory where you’ll put the majority of your application’s code. config/ A directory for your application’s configuration, including things like routes, settings and Puma configuration. config.ru A Rack config file. lib/ A directory for supporting code. spec/ The application’s RSpec test suite.
Code autoloading helps you work with minimal fuss • Autoload not just application code but dependencies which means faster boot times ◦ Doesn’t have to eager load every constant ever at boot time…unlike Rails • App core itself is special ◦ Can use the app object itself to load and return any individual component ◦ Hanami.app["actions.food.index"] • Hanami console, like a supercharged Rails console
- Dependency injection is easy - include Deps["key"], the Deps mixin allows a component to use any other component in its container as a dependency - Easier to code up tests too! Just inject your mocks Deps - friendly dependency injection helper
areas of concern. Built-in facility for organizing your code, encouraging maintainable boundaries, and creating operational flexibility. Just like a miniature Hanami app in your Hanami app!
generate action home.show • Create Database Migration $ bundle exec rake db:create_migration[create_books] • Create a whole app $ hanami new picnic • Or a smaller part of the app, a slice $ hanami generate slice api • And in the slice $ hanami generate action food.show --slice api
• Slices can deploy out as their own containers (mini contained apps…) • Great for APIs • Deps really is a great way to make it easy to create reusable components that are easy to test • Dry::CLI is a joy to compose together developer centric tasks
learning curve vs ActiveRecord • Frontend integration is not there yet…dry-view integration is not available yet • Dry-rb and understanding the functional programming is still necessary to get all the benefits of Hanami
minutes - How it has sped up new feature development - Deployed 15 actions spanning 3 different slices - Test Time - Running each slice full test suite is quick
Omaha, NE 📚 likes to read too much 🥙🍜🍛 eats food that probably took too long to prepare Professionally solving problems on the Identity team at WP Engine christine-seeman.com