http://www.catalystframework.org/
cpan Catalyst::Devel cpan Catalyst::View::TT cpan Catalyst::Model::DBIC::Schema cpan DBIx::Class::Schema::Loader
and accept the default for a lot of questions...
catalyst.pl MadMongers cd MadMongers script/madmongers_create.pl view TT TT script/madmongers_server.pl open http://localhost:3000/
package MadMongers; use strict; use warnings; use Catalyst::Runtime; use Catalyst qw/-Debug ConfigLoader Static::Simple/; __PACKAGE__->config( name => 'MadMongers' ); __PACKAGE__->setup; 1;
package MadMongers::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default : Private { my ( $self, $c ) = @_; $c->response->body( $c->welcome_message ); } sub end : ActionClass('RenderView') {} 1;
create table meetings ( id INTEGER PRIMARY KEY NOT NULL, topic text, mtg_when date, location text ); insert into meetings VALUES (1, 'Lightning talks', '2007-06-14', 'Madison Public Library'); insert into meetings VALUES (2, 'Quick and Dirty', '2007-07-12', 'Madison Public Library');Create:
sqlite3 /tmp/madmongers.db < schema.sql
script/madmongers_create.pl model DB DBIC::Schema Schema create=static \ 'dbi:SQLite:/tmp/madmongers.db'
sub meetings : Local { my ( $self, $c ) = @_; $c->stash->{meetings} = [ $c->model('DB::meetings')->all ]; $c->stash->{template} = 'meetings.tt'; }
<h1>Meetings</h1> <ul> [% FOR meeting = meetings %] <li><b>[% meeting.topic %]</b> when: [% meeting.mtg_when %], where: [% meeting.location %]</li> [% END %] </ul>