DEV Community

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

Posted on

9 2

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!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (2)

Collapse
 
grinnz profile image
Dan • 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 😃

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay