The Sysadmin Notebook  

Sitemap

Catalyst Tutorial Notes

Notes on the Catalyst Tutorial

Contents

Install Task::Catalyst::Tutorial

Example applications can be found at Catalyst Repository Example Applications (see also: Catalyst Wiki)

MVC

Top Bottom

MVC is a design pattern keeping the three main areas of an application seperate, so that anyone can be replaced without affecting the other. The three areas are:

Create Project

Top Bottom

use 'catalyst.pl MyApp' to initialise the application framework - creates MyApp directory and subdirectories required for the project

Start the server with script/myapp_server.pl. Options include:

The Application Class

Top Bottom

lib/MyApp.pm

Contains the list of plugins/flags in use by the application. Defaults are -Debug (flag); Catalyst::Plugin::ConfigLoader (provides automatic loader of configuration parameters; Catalyst::Plugin::Static::Simple (provides services for static content, eg CSS and images). Additional Plugins: Catalyst::Plugin::StackTrace (sends errors to the browser); Catalyst::Model::DBI (access databases through traditional DBI interface; Class::DBI (traditional perl ORM engine, providing model objects for relational databases); DBIx::Class (preferred ORM engine).

The Model

Top Bottom

use the Catalyst::Helper::Model::DBIC::Schema helper script to create the model class:

script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB dbi:SQLite:myapp.db '' '' '{AutoCommit => 1}'

where the first 'MyAppDB' is the name of the class to be created (in lib/MyApp/Model) and the second is the name of the schema file to be used to create the model (lib/MyAppDB.pm)

The Controller

Top Bottom

Controllers contain methods that interact with user input. To create a controller for book-related actions:

script/myapp_create.pl controller Books

The View

Top Bottom

Use the Catalyst::Helper::View::TT or Catalyst::Helper::View::TTSite helper script to create the View:

script/myapp_create.pl view TT TTSite