- Detailed Table of Contents
Catalyst::Manual::Tutorial - Catalyst Tutorial: Overview
The Catalyst framework is a flexible and comprehensive environment for quickly building high-functionality web applications. This tutorial is designed to provide a rapid introduction to its basics and its most commonly used features while focusing on real-world best practices.
The tutorial is divided into the following sections:
NOTE: CLICK THESE LINKS TO JUMP TO CHAPTERS (the index links above only navigate inside this page).
A tarball of the final application is available at http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz.
VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
WHERE TO GET WORKING CODE
CREATE A CATALYST PROJECT
The Simplest Way
Hello, World! Using a View and a Template
CREATE A SIMPLE CONTROLLER AND AN ACTION
CREATE A NEW APPLICATION
EDIT THE LIST OF CATALYST PLUGINS
CREATE A CATALYST CONTROLLER
Create a Catalyst View Using TTSite
Globally Customize Every View
Create a TT Template Page
CREATE A SQLITE DATABASE
DATABASE ACCESS WITH DBIx::Class
Create a Dynamic DBIC Model
RUN THE APPLICATION
A STATIC DATABASE MODEL WITH DBIx::Class
Create Static DBIC Schema Files
Updating the Generated DBIC Schema Files
RUN THE APPLICATION
RUNNING THE APPLICATION FROM THE COMMAND LINE
UPDATING THE VIEW
Using RenderView for the Default View
Using The Default Template Name
Return To A Manually-Specified Template
Include a Create Action in the Books Controller
Include a Template for the url_create Action:
Try the url_create Feature
MANUALLY BUILDING A CREATE FORM
Add a Method to Display the Form
Add a Template for the Form
Add Method to Process Form Values and Update Database
Test Out the Form
A SIMPLE DELETE FEATURE
Include a Delete Link in the List
Add a Delete Action to the Controller
Try the Delete Feature
Fixing a Dangerous URL
Try the Delete and Redirect Logic
Using uri_for to Pass Query Parameters
Try the Delete and Redirect With Query Param Logic
Add Users and Roles to the Database
Add User and Role Information to DBIC Schema
Sanity-Check Reload of Development Server
Include Authentication and Session Plugins
Add Login and Logout Controllers
Add a Login Form TT Template Page
Add Valid User Check
Displaying Content Only to Authenticated Users
Try Out Authentication
USING PASSWORD HASHES
Get a SHA-1 Hash for the Password
Switch to SHA-1 Password Hashes in the Database
Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
Try Out the Hashed Passwords
USING THE SESSION FOR FLASH
Try Out Flash
Switch To Flash-To-Stash
Update Plugins to Include Support for Authorization
Add Config Information for Authorization
Add Role-Specific Logic to the ``Book List'' Template
Limit Books::add to admin Users
Try Out Authentication And Authorization
ENABLE ACL-BASED AUTHORIZATION
Add the Catalyst::Plugin::Authorization::ACL Plugin
Add ACL Rules to the Application Class
Add a Method to Handle Access Violations
RUNNING CATALYST UNDER THE PERL DEBUGGER
DEBUGGING MODULES FROM CPAN
RUNNING THE "CANNED" CATALYST TESTS
RUNNING A SINGLE TEST
ADDING YOUR OWN TEST SCRIPT
SUPPORTING BOTH PRODUCTION AND TEST DATABASES
ADVANCED CRUD OPTIONS
APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
"Un-indenting" with Vi/Vim
"Un-indenting" with Emacs
APPENDIX 2: USING MYSQL AND POSTGRESQL
APPENDIX 3: IMPROVED HASHING SCRIPT
This tutorial would not have been possible without the input of many different people in the Catalyst community. In particular, the primary author would like to thank:
Sebastian Riedel for founding the Catalyst project.
The members of the Catalyst Core Team for their tireless efforts to advance the Catalyst project. Although all of the Core Team members have played a key role in this tutorial, it would have never been possible without the critical contributions of: Matt Trout, for his unfathomable knowledge of all things Perl and Catalyst (and his willingness to answer lots of my questions); Jesse Sheidlower, for his incredible skill with the written word and dedication to improving the Catalyst documentation; and Yuval Kogman, for his work on the Catalyst "Auth & Authz" plugins (the original focus of the tutorial) and other key Catalyst modules.
Other Catalyst documentation folks like Kieren Diment, Gavin Henry, and Jess Robinson (including their work on the original Catalyst tutorial).
Kieren Diment for currently maintaining this document on CPAN.
Everyone on #catalyst and #catalyst-dev.
Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the PostgreSQL content in the Appendix.
People who have emailed me with corrections and suggestions on the tutorial. As of the most recent release, this include: Florian Ragwitz, Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno, Bryan Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning Sprang, Jeremy Jones, David Kurtz, Ingo Wichmann, and Shlomi Fish. I'm sure I am missing some names here... apologies for that (please let me know if you name should be here).
Please report any errors, issues or suggestions to the author. The most recent version of the Catalyst Tutorial can be found at http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/.
Copyright 2006-2008, Kennedy Clark, under Creative Commons License (http://creativecommons.org/licenses/by-nc-sa/2.5/).