19 November 2008
This post may be outdated due to it was written on 2008. The links may be broken. The code may be not working anymore. Leave comments if needed.
Mojo is created by sri, the one who created Catalyst.
since sri is very SMART, we should follow him a bit.

Mojo is not a web framework. it is "a collection of libraries and example web frameworks for web framework developers.". u can treat it as something like Catalyst::Engine or HTTP::Engine.

but Mojolicious is a web framework built on Mojo.

install Mojo should be very simple and it doesn't have the half of CPAN. :)

start a project based on Mojolicous, you just type:
mojolicious generate app DayDayUp
cd day_day_up
perl bin/day_day_up deamon
then you can view a sample through

it's like Catalyst but it's really much more faster than catalyst server.pl

Mojolicous is still in its early stage. but luckily, we have MojoX::Renderer::TT by ask.

something inside:
1, in Controller $c, it is an instance of DayDayUp::Context which based on Mojolicious::Context.
check http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp/Context.pm
we added config and dbh there. after this, you can call $c->config and $c->dbh in controller like
it's very flexible. you can add DBIx::Class there, it's not a problem.
2, routines. you don't have any :Global :Regex :Chained in Mojolicous. instead, we defined all those url mapping things in DayDayUp.pm sub start.
indeed, I like it. :)
remember it has an order. so you should put the default at the last of routines like
    # route
$r->route('/notes/:id/:action', id => qr/\d+/)
->to(controller => 'notes', action => 'index');
# Default route
->to(controller => 'index', action => 'index');

set ENV MOJOX_ROUTES_DEBUG on that you can debug the dispatch.
(1) / is matching ":/controller/:action" with default controller => 'index', action => 'index'
(2) /notes is matching ":/contorller/:action" with controller to be notes and action still be index.
(3) /notes/add is matching ":/controller/:action" with controller "notes" and action "add"
(4) /notes/1/edit is matching '/notes/:id/:action' with action as edit.
much much more you can find it here: Mojo::Manual::Mojolicious
it's simple but powerful.

I'll write more next time. but it's for now.


blog comments powered by Disqus