DEV Community

Cover image for Migrate to Mojolicious 9 - Quick feedback
Tib
Tib

Posted on

Migrate to Mojolicious 9 - Quick feedback

Today I migrated one application to Mojolicious 9 🎉

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);
Enter fullscreen mode Exit fullscreen mode

per something like:

my $auth = $r->under('/members')->requires(authenticated => 1);
Enter fullscreen mode Exit fullscreen mode

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);
Enter fullscreen mode Exit fullscreen mode

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!

Latest comments (2)

Collapse
 
grinnz profile image
Dan Book • Edited

I don't know where you were trying to get decode_json from previously - it has been in Mojo::JSON approximately forever, but see the Upgrading document in the Mojolicious wiki for breaking changes to watch for when upgrading.

Collapse
 
thibaultduponchelle profile image
Tib

Thank you, I added this link in the post 😃