Migrate to Mojolicious 9 - Quick feedback
Tib
Posted on March 25, 2021
Today I migrated one application to Mojolicious 9 🎉
Since I had some errors, I just wanted to share if it could help others to migrate quickly.
EDIT: as commented by @grinnz, there is the upgrading document that should be checked for tips before any attempt to migrate.
It's not a big application (~2000 lines of code) but it has authentication, external calls, DB access and a flat config loaded at startup. It uses some plugins like Authentication, Status, Config and AccessLog.
I like to think it is a small but good coverage of Mojolicious features.
I said I had errors, but actually very few and I will give my solutions right below.
Can't locate object method "route" via package "Mojolicious::Routes"
In my case it was a matter of replacing something like:
my $auth = $r->route('/members')->over(authenticated => 1);
per something like:
my $auth = $r->under('/members')->requires(authenticated => 1);
I wonder if code snippets shown on Mojolicious::Plugin::Authentication doc are still valid for Mojolicious 9 (?).
Undefined subroutine &App::Controller::App::decode_json called
This sub seems to have moved, I fixed by simply adding:
use Mojo::JSON qw(decode_json encode_json);
Conclusion
I like Mojolicious ❤️ and the way it is so actively developed. It's true that there is sometimes some small breakages (I remember in the past a breakage about slurp) but it is always well documented and painless 👍
Long live to Mojolicious!
Posted on March 25, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 23, 2021