Shell for Catalyst

Published: April 21, 2010

Antano Solar John is the creator and developer of the most advanced technologies to design and fast-track personal evolution and an investor in startups that have access to cutting-edge solutions for personal excellence.

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;

Related Posts

Rails on Lion

Rails on Lion

Ruby HTTP Post with JSON Request + SSL + Certificate + Basic Authentication

Ruby HTTP Post with JSON Request + SSL + Certificate + Basic Authentication

Tools & Showcase

Tools & Showcase

5 Min Mentor – Quick and Measurable Learning by Content Free Diagnosis

5 Min Mentor – Quick and Measurable Learning by Content Free Diagnosis

The Antano Solar Voice  is one of the most cutting-edge blog and podcast in the world with fresh insights from validated life experience. The Solar Voice season 1 podcast has been ranked #3 in Apple iTunes News & Noteworthy. And the posts have been published in over a dozen publications including Business World, YourStory, Hindu Business Line, Economic Times and  many more. To listen to any of the past episodes for free, check out this page. And to read the past article, check out the blog page.

Leave a Reply


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

  1. 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

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}