Most modern MVC frameworks come with a shell (REPL) that makes debugging and development a lot easier. In catalyst this is not out of the box.
However below is a script that you can add to the script directory. This will connect to your schema directly. There is a catalystx plugin CatalystX::REPL that uses moose which is far more helpful. However I will update on that once I have tried it. For now that script to get an interactive shell to play with your models.
use Devel::REPL;
my $repl = Devel::REPL->new;
$repl->load_plugin(‘LexEnv’);
$repl->lexical_environment->do(<<‘CODEZ’);
use FindBin;
use lib “$FindBin::Bin/../lib”;
use Cl::Model::Cl;my $modelconfig = Cl::Model::Cl->config;
my $schema_class = $modelconfig->{schema_class};
my $dsn = $modelconfig->{connect_info}->{dsn};
my $user = $modelconfig->{connect_info}->{user};
my $password = $modelconfig->{connect_info}->{password};eval “use $schema_class”;
my $s = $schema_class->connect($dsn,$user,$password);CODEZ
$repl->run;
Nice post, this seems to be exactly what I was looking for! I cannot get it to run though, I get this error:
Can’t locate Cl/Model/Cl.pm in @INC
I’m kind of a noob in both Perl and Catalyst, so this probably has to do with something I did wrong, but can you give me a little help here?
TYA
Andre
you need to replace Cl::Model::Cl with the namespace of your model