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:
14 B<NOTE: CLICK THESE LINKS TO JUMP TO CHAPTERS> (the index links above
15 only navigate inside this page).
21 L<Introduction|Catalyst::Manual::Tutorial::01_Intro>
25 L<Catalyst Basics|Catalyst::Manual::Tutorial::02_CatalystBasics>
29 L<More Catalyst Basics|Catalyst::Manual::Tutorial::03_MoreCatalystBasics>
33 L<Basic CRUD|Catalyst::Manual::Tutorial::04_BasicCRUD>
37 L<Authentication|Catalyst::Manual::Tutorial::05_Authentication>
41 L<Authorization|Catalyst::Manual::Tutorial::06_Authorization>
45 L<Debugging|Catalyst::Manual::Tutorial::07_Debugging>
49 L<Testing|Catalyst::Manual::Tutorial::08_Testing>
53 L<Advanced CRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD>
57 L<Appendices|Catalyst::Manual::Tutorial::10_Appendices>
61 Final code tarballs for each chapter of the tutorial are available at
62 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/>.
65 =head1 Detailed Table of Contents
68 =head2 L<Chapter 1: Intro|Catalyst::Manual::Tutorial::01_Intro>
70 Note: Click on the heading in the previous line to jump to the actual
71 chapter. Below is a "table of contents" for this chapter.
77 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
89 WHERE TO GET WORKING CODE
94 =head2 L<Chapter 2: Catalyst Basics|Catalyst::Manual::Tutorial::02_CatalystBasics>
96 Note: Click on the heading in the previous line to jump to the actual
97 chapter. Below is a "table of contents" for this chapter.
103 CREATE A CATALYST PROJECT
117 Hello, World! Using a View and a Template
123 CREATE A SIMPLE CONTROLLER AND AN ACTION
128 =head2 L<Chapter 3: More Catalyst Basics|Catalyst::Manual::Tutorial::03_MoreCatalystBasics>
130 Note: Click on the heading in the previous line to jump to the actual
131 chapter. Below is a "table of contents" for this chapter.
137 CREATE A NEW APPLICATION
141 EDIT THE LIST OF CATALYST PLUGINS
145 CREATE A CATALYST CONTROLLER
156 Create a Catalyst View
160 Create a TT Template Page
164 Test Run The Application
170 CREATE A SQLITE DATABASE
174 DATABASE ACCESS WITH DBIx::Class
180 Create a Dynamic DBIC Model
186 ENABLE THE MODEL IN THE CONTROLLER
192 Test Run The Application
198 CREATE A WRAPPER FOR THE VIEW
204 Configure TT.pm For The Wrapper
208 Create the Wrapper Template File and Stylesheet
212 Test Run The Application
218 A STATIC DATABASE MODEL WITH DBIx::Class
224 Create Static DBIC Schema Files
228 Updating the Generated DBIC Schema Files
242 RUNNING THE APPLICATION FROM THE COMMAND LINE
252 Using RenderView for the Default View
256 Using The Default Template Name
260 Return To A Manually-Specified Template
267 =head2 L<Chapter 4: Basic CRUD|Catalyst::Manual::Tutorial::04_BasicCRUD>
269 Note: Click on the heading in the previous line to jump to the actual
270 chapter. Below is a "table of contents" for this chapter.
282 Include a Create Action in the Books Controller
286 Include a Template for the url_create Action:
290 Try the url_create Feature
296 CONVERT TO A CHAINED ACTION
302 Try the Chained Action
306 Refactor to Use a "Base" Method to Start the Chains
312 MANUALLY BUILDING A CREATE FORM
318 Add a Method to Display the Form
322 Add a Template for the Form
326 Add Method to Process Form Values and Update Database
336 A SIMPLE DELETE FEATURE
342 Include a Delete Link in the List
346 Add a Common Method to Retrieve a Book for the Chain
350 Add a Delete Action to the Controller
354 Try the Delete Feature
358 Fixing a Dangerous URL
362 Try the Delete and Redirect Logic
366 Using uri_for to Pass Query Parameters
370 Try the Delete and Redirect With Query Param Logic
376 EXPLORING THE POWER OF DBIC
382 Add Datetime Columns to Our Existing Books Table
386 Update DBIC to Automatically Handle the Datetime Columns
390 Create a ResultSet Class
398 Adding Methods to Result Classes
405 =head2 L<Chapter 5: Authentication|Catalyst::Manual::Tutorial::05_Authentication>
407 Note: Click on the heading in the previous line to jump to the actual
408 chapter. Below is a "table of contents" for this chapter.
420 Add Users and Roles to the Database
424 Add User and Role Information to DBIC Schema
428 Sanity-Check Reload of Development Server
432 Include Authentication and Session Plugins
436 Configure Authentication
440 Add Login and Logout Controllers
444 Add a Login Form TT Template Page
452 Displaying Content Only to Authenticated Users
456 Try Out Authentication
462 USING PASSWORD HASHES
468 Get a SHA-1 Hash for the Password
472 Switch to SHA-1 Password Hashes in the Database
476 Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
480 Try Out the Hashed Passwords
486 USING THE SESSION FOR FLASH
496 Switch To Flash-To-Stash
503 =head2 L<Chapter 6: Authorization|Catalyst::Manual::Tutorial::06_Authorization>
505 Note: Click on the heading in the previous line to jump to the actual
506 chapter. Below is a "table of contents" for this chapter.
518 Update Plugins to Include Support for Authorization
522 Add Config Information for Authorization
526 Add Role-Specific Logic to the ``Book List'' Template
530 Limit Books::add to admin Users
534 Try Out Authentication And Authorization
540 ENABLE MODEL-BASED AUTHORIZATION
545 =head2 L<Chapter 7: Debugging|Catalyst::Manual::Tutorial::07_Debugging>
547 Note: Click on the heading in the previous line to jump to the actual
548 chapter. Below is a "table of contents" for this chapter.
558 RUNNING CATALYST UNDER THE PERL DEBUGGER
562 DEBUGGING MODULES FROM CPAN
571 =head2 L<Chapter 8: Testing|Catalyst::Manual::Tutorial::08_Testing>
573 Note: Click on the heading in the previous line to jump to the actual
574 chapter. Below is a "table of contents" for this chapter.
580 RUNNING THE "CANNED" CATALYST TESTS
584 RUNNING A SINGLE TEST
588 ADDING YOUR OWN TEST SCRIPT
592 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
597 =head2 L<Chapter 9: Advanced CRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD>
599 Note: Click on the heading in the previous line to jump to the actual
600 chapter. Below is a "table of contents" for this chapter.
606 ADVANCED CRUD OPTIONS
611 =head2 L<Chapter 10: Appendices|Catalyst::Manual::Tutorial::10_Appendices>
613 Note: Click on the heading in the previous line to jump to the actual
614 chapter. Below is a "table of contents" for this chapter.
620 APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
626 "Un-indenting" with Vi/Vim
630 "Un-indenting" with Emacs
636 APPENDIX 2: USING MYSQL AND POSTGRESQL
652 APPENDIX 3: IMPROVED HASHING SCRIPT
659 This tutorial would not have been possible without the input of many
660 different people in the Catalyst community. In particular, the
661 primary author would like to thank:
667 Sebastian Riedel for founding the Catalyst project.
671 The members of the Catalyst Core Team for their tireless efforts to
672 advance the Catalyst project. Although all of the Core Team members
673 have played a key role in this tutorial, it would have never been
674 possible without the critical contributions of: Matt Trout, for his
675 unfathomable knowledge of all things Perl and Catalyst (and his
676 willingness to answer lots of my questions); Jesse Sheidlower, for his
677 incredible skill with the written word and dedication to improving the
678 Catalyst documentation; and Yuval Kogman, for his work on the Catalyst
679 "Auth & Authz" plugins (the original focus of the tutorial) and other
680 key Catalyst modules.
684 Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
685 and Jess Robinson (including their work on the original Catalyst
690 Kieren Diment for his oversite of Catalyst-related documentation.
694 Everyone on #catalyst and #catalyst-dev.
698 Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the
699 PostgreSQL content in the Appendix.
703 People who have emailed me with corrections and suggestions on the
704 tutorial. As of the most recent release, this include: Florian
705 Ragwitz, Mauro Andreolini, Jim Howard, Giovanni Gigante, William
706 Moreno, Bryan Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning
707 Sprang, Jeremy Jones, David Kurtz, Ingo Wichmann, Shlomi Fish, Murray
708 Walker and Adam Witney. Thanks to Devin Austin for coming up with an
709 initial version of a non-TTSite wrapper page. Also, a huge thank you
710 to Kiffin Gish for all the hard work on the "database depluralization"
711 effort! I'm sure I am missing some names here... apologies for that
712 (please let me know if you name should be here).
718 Kennedy Clark, C<hkclark@gmail.com>
720 Please report any errors, issues or suggestions to the author. The
721 most recent version of the Catalyst Tutorial can be found at
722 L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>.
724 Copyright 2006-2008, Kennedy Clark, under Creative Commons License
725 (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).