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::Intro>
25 L<Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
29 L<More Catalyst Basics|Catalyst::Manual::Tutorial::MoreCatalystBasics>
33 L<Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD>
37 L<Authentication|Catalyst::Manual::Tutorial::Authentication>
41 L<Authorization|Catalyst::Manual::Tutorial::Authorization>
45 L<Debugging|Catalyst::Manual::Tutorial::Debugging>
49 L<Testing|Catalyst::Manual::Tutorial::Testing>
53 L<Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
57 L<Appendices|Catalyst::Manual::Tutorial::Appendices>
61 Tarballs for the final code for each part of the tutorial is available
63 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/>.
66 =head1 Detailed Table of Contents
69 =head2 L<Part 1: Introduction|Catalyst::Manual::Tutorial::Intro>
75 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
87 WHERE TO GET WORKING CODE
92 =head2 L<Part 2: Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
98 CREATE A CATALYST PROJECT
112 Hello, World! Using a View and a Template
118 CREATE A SIMPLE CONTROLLER AND AN ACTION
123 =head2 L<Part 3: More Catalyst Basics|Catalyst::Manual::Tutorial::MoreCatalystBasics>
130 CREATE A NEW APPLICATION
134 EDIT THE LIST OF CATALYST PLUGINS
138 CREATE A CATALYST CONTROLLER
149 Create a Catalyst View Using TTSite
153 Globally Customize Every View
157 Create a TT Template Page
163 CREATE A SQLITE DATABASE
167 DATABASE ACCESS WITH DBIx::Class
173 Create a Dynamic DBIC Model
183 A STATIC DATABASE MODEL WITH DBIx::Class
189 Create Static DBIC Schema Files
193 Updating the Generated DBIC Schema Files
203 RUNNING THE APPLICATION FROM THE COMMAND LINE
213 Using RenderView for the Default View
217 Using The Default Template Name
221 Return To A Manually-Specified Template
228 =head2 L<Part 4: Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD>
240 Include a Create Action in the Books Controller
244 Include a Template for the url_create Action:
248 Try the url_create Feature
254 MANUALLY BUILDING A CREATE FORM
260 Add a Method to Display the Form
264 Add a Template for the Form
268 Add Method to Process Form Values and Update Database
278 A SIMPLE DELETE FEATURE
284 Include a Delete Link in the List
288 Add a Delete Action to the Controller
292 Try the Delete Feature
296 Fixing a Dangerous URL
300 Try the Delete and Redirect Logic
304 Using uri_for to Pass Query Parameters
308 Try the Delete and Redirect With Query Param Logic
315 =head2 L<Part 5: Authentication|Catalyst::Manual::Tutorial::Authentication>
327 Add Users and Roles to the Database
331 Add User and Role Information to DBIC Schema
335 Sanity-Check Reload of Development Server
339 Include Authentication and Session Plugins
343 Configure Authentication
347 Add Login and Logout Controllers
351 Add a Login Form TT Template Page
359 Displaying Content Only to Authenticated Users
363 Try Out Authentication
369 USING PASSWORD HASHES
375 Get a SHA-1 Hash for the Password
379 Switch to SHA-1 Password Hashes in the Database
383 Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
387 Try Out the Hashed Passwords
393 USING THE SESSION FOR FLASH
403 Switch To Flash-To-Stash
410 =head2 L<Part 6: Authorization|Catalyst::Manual::Tutorial::Authorization>
422 Update Plugins to Include Support for Authorization
426 Add Config Information for Authorization
430 Add Role-Specific Logic to the ``Book List'' Template
434 Limit Books::add to admin Users
438 Try Out Authentication And Authorization
444 ENABLE ACL-BASED AUTHORIZATION
450 Add the Catalyst::Plugin::Authorization::ACL Plugin
454 Add ACL Rules to the Application Class
458 Add a Method to Handle Access Violations
465 =head2 L<Part 7: Debugging|Catalyst::Manual::Tutorial::Debugging>
475 RUNNING CATALYST UNDER THE PERL DEBUGGER
479 DEBUGGING MODULES FROM CPAN
484 =head2 L<Part 8: Testing|Catalyst::Manual::Tutorial::Testing>
490 RUNNING THE "CANNED" CATALYST TESTS
494 RUNNING A SINGLE TEST
498 ADDING YOUR OWN TEST SCRIPT
502 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
507 =head2 L<Part 9: Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
513 ADVANCED CRUD OPTIONS
518 =head2 L<Part 10: Appendices|Catalyst::Manual::Tutorial::Appendices>
524 APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
530 "Un-indenting" with Vi/Vim
534 "Un-indenting" with Emacs
540 APPENDIX 2: USING MYSQL AND POSTGRESQL
556 APPENDIX 3: IMPROVED HASHING SCRIPT
563 This tutorial would not have been possible without the input of many
564 different people in the Catalyst community. In particular, the
565 primary author would like to thank:
571 Sebastian Riedel for founding the Catalyst project.
575 The members of the Catalyst Core Team for their tireless efforts to
576 advance the Catalyst project. Although all of the Core Team members
577 have played a key role in this tutorial, it would have never been
578 possible without the critical contributions of: Matt Trout, for his
579 unfathomable knowledge of all things Perl and Catalyst (and his
580 willingness to answer lots of my questions); Jesse Sheidlower, for his
581 incredible skill with the written word and dedication to improving the
582 Catalyst documentation; and Yuval Kogman, for his work on the Catalyst
583 "Auth & Authz" plugins (the original focus of the tutorial) and other
584 key Catalyst modules.
588 Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
589 and Jess Robinson (including their work on the original Catalyst
594 Kieren Diment for his oversite of Catalyst-related documentation.
598 Everyone on #catalyst and #catalyst-dev.
602 Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the
603 PostgreSQL content in the Appendix.
607 People who have emailed me with corrections and suggestions on the
608 tutorial. As of the most recent release, this include: Florian Ragwitz,
609 Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno, Bryan
610 Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning Sprang, Jeremy
611 Jones, David Kurtz, Ingo Wichmann, and Shlomi Fish. Also, thanks to
612 Devin Austin for coming up with an initial version of a non-TTSite
613 wrapper page. I'm sure I am missing some names here... apologies for
614 that (please let me know if you name should be here).
620 Kennedy Clark, C<hkclark@gmail.com>
622 Please report any errors, issues or suggestions to the author. The
623 most recent version of the Catalyst Tutorial can be found at
624 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
626 Copyright 2006-2008, Kennedy Clark, under Creative Commons License
627 (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).