3 Catalyst::Manual::Tutorial - Catalyst Tutorial: Overview
7 The Catalyst framework is a flexible and comprehensive environment for
8 quickly building high-functionality web applications. This tutorial is
9 designed to provide a rapid introduction to its basics and its most
10 commonly used features while focusing on real-world best practices.
12 The tutorial is divided into the following sections:
18 L<Introduction|Catalyst::Manual::Tutorial::Intro>
22 L<Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
26 L<Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD>
30 L<Authentication|Catalyst::Manual::Tutorial::Authentication>
34 L<Authorization|Catalyst::Manual::Tutorial::Authorization>
38 L<Testing|Catalyst::Manual::Tutorial::Testing>
42 L<Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
46 L<Appendices|Catalyst::Manual::Tutorial::Appendices>
50 A tarball of the final application is available at
51 C<to_be_compled_in_final_version>.
53 =head1 Detailed Table Of Contents
55 =head2 Part 1: Introduction
61 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
73 WHERE TO GET WORKING CODE
78 =head2 Part 2: Catalyst Application Development Basics
84 CREATE A CATALYST PROJECT
88 CREATE A SQLITE DATABASE
92 EDIT THE LIST OF CATALYST PLUGINS
96 DATABASE ACCESS WITH DBIx::Class
103 Create a DBIC Schema File
107 Create the DBIC ``Result Source'' Files
111 Use Catalyst::Model::DBIC::Schema to Load the Model Class
118 CREATE A CATALYST CONTROLLER
129 Create a Catalyst View Using TTSite
133 Using RenderView for the Default View
137 Globally Customize Every View
141 Create a TT Template Page
152 =head2 Part 3: Basic CRUD
164 Include a Create Action in the Books Controller
168 Include a Template for the url_create Action:
172 Try the url_create Feature
178 MANUALLY BUILDING A CREATE FORM
184 Add a Method to Display the Form
188 Add a Template for the Form
192 Add Method to Process Form Values and Update Database
202 A SIMPLE DELETE FEATURE
208 Include a Delete Link in the List
212 Add a Delete Action to the Controller
216 Try the Delete Feature
222 =head2 Part 4: Authentication
234 Add Users and Roles to the Database
238 Add User and Role Information to DBIC Schema
242 Create New ``Result Source Objects''
246 Sanity-Check Reload of Development Server
250 Include Authentication and Session Plugins
254 Configure Authentication
258 Add Login and Logout Controllers
262 Add a Login Form TT Template Page
270 Displaying Content Only to Authenticated Users
274 Try Out Authentication
280 USING PASSWORD HASHES
286 Get a SHA-1 Hash for the Password
290 Switch to SHA-1 Password Hashes in the Database
294 Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
298 Try Out the Hashed Passwords
304 =head2 Part 5: Authorization
316 Update Plugins to Include Support for Authorization
320 Add Config Information for Authorization
324 Add Role-Specific Logic to the ``Book List'' Template
328 Limit Books::add to admin Users
332 Try Out Authentication And Authorization
338 ENABLE ACL-BASED AUTHORIZATION
344 Add the Catalyst::Plugin::Authorization::ACL Plugin
348 Add ACL Rules to the Application Class
352 Add a Method to Handle Access Violations
358 =head2 Part 6: Debugging
368 RUNNING CATALYST UNDER THE PERL DEBUGGER
372 DEBUGGING MODULES FROM CPAN
376 =head2 Part 7: Testing
382 RUNNING THE "CANNED" CATALYST TESTS
386 RUNNING A SINGLE TEST
390 ADDING YOUR OWN TEST SCRIPT
394 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
398 =head2 Part 8: Advanced CRUD
404 HTML::WIDGET FORM CREATION
410 Add the HTML::Widget Plugin
414 Add a Form Creation Helper Method
418 Add Actions to Display and Save the Form
426 Create a Template Page To Display The Form
430 Add Links for Create and Update via HTML::Widget
434 Test The <HTML::Widget> Create Form
440 HTML::WIDGET VALIDATION AND FILTERING
446 Add Constraints and Filters to the Widget Creation Method
450 Rebuild the Form Submission Method to Include Validation
460 Enable DBIx::Class::HTMLWidget Support
466 Add DBIx::Class::HTMLWidget to DBIC Model
470 Use populate_from_widget in hw_create_do
476 =head2 Part 9: Appendices
482 APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
488 "Un-indenting" with Vi/Vim
492 "Un-indenting" with Emacs
498 APPENDIX 2: USING MYSQL AND POSTGRESQL
514 APPENDIX 3: IMPROVED HASHING SCRIPT
521 This tutorial would not have been possible without the input of many
522 different people in the Catalyst community. In particular, the
523 primary author would like to thank:
529 Sebastian Riedel for founding the Catalyst project.
533 The members of the Catalyst Core Team for their tireless efforts to
534 advance the Catalyst project. Although all of the Core Team members
535 have played a key role in this tutorial, it would have never been
536 possible without the critical contributions of: Matt Trout, for his
537 unfathomable knowledge of all things Perl and Catalyst (and his
538 willingness to answer lots of my questions); Jesse Sheidlower, for his
539 incredible skill with the written word and dedication to improving the
540 Catalyst documentation; and Yuval Kogman, for his work on the Catalyst
541 "Auth & Authz" plugins (the original focus of the tutorial) and other
542 key Catalyst modules.
546 Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
547 and Jess Robinson (including their work on the original Catalyst
552 Everyone on #catalyst and #catalyst-dev.
556 People who have emailed me with corrections and suggestions on the
557 tutorial. As of the most recent release, this include: Florian Ragwitz,
558 Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno,
559 Bryan Roach, Ashley Berlin, and David Kamholz.
567 Kennedy Clark, C<hkclark@gmail.com>
569 Please report any errors, issues or suggestions to the author. The
570 most recent version of the Catalyst Tutorial can be found at
571 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
573 Copyright 2006, Kennedy Clark, under Creative Commons License
574 (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).