I changed a few things and did some progress (I think)...

First, rename the whole thing from Lib to MyLib and reread the doc

My +folders are now
run.pl my_lib.conf +templates common_js.html.ep invtot.html.ep libmap.html.ep +layouts default.html.ep +public index.html some .js files +lib MyLib.pm +MyLib Invtot.pm +Controller Invtot.pm
I have the post action starting until it crashes on the line trying to fetch the database handler which is get from startup in package MyLib::Invtot. The whole file is
package MyLib::Invtot; use Mojo::Base 'Mojolicious'; sub startup { my $app = shift; my $config = $app->config; $app->log->debug("connecting..."); $app->plugin( 'Database', { dsn => 'dbi:mysql:host=mysql.unifr.ch:dbname=dokpe_i0 +1', username => $config->{username}, password => $config->{password}, options => { 'pg_enable_utf8' => 1, AutoCommit => 1, PrintError => 0, RaiseError => 1 }, helper => 'db', } ); } 1;
and the call to helper => db should make it accessible to the controller in MyLib/Controller/Invtot. That's not the case and I'm not even sure it's called at all. How can I make sure the connection is made the first time the invtot page is load and how can I then retrieve the database connection in the controller ?

Thanks


In reply to Re: First steps with Mojolicious by frazap
in thread First steps with Mojolicious by frazap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.