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;

  • Share/Bookmark

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>