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