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 A tarball of the final application is available at
62 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz>.
65 =head1 Detailed Table of Contents
68 =head2 L<Part 1: Introduction|Catalyst::Manual::Tutorial::Intro>
74 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
86 WHERE TO GET WORKING CODE
91 =head2 L<Part 2: Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
97 CREATE A CATALYST PROJECT
111 Hello, World! Using a View and a Template
117 CREATE A SIMPLE CONTROLLER AND AN ACTION
122 =head2 L<Part 3: More Catalyst Basics|Catalyst::Manual::Tutorial::MoreCatalystBasics>
129 CREATE A NEW APPLICATION
133 EDIT THE LIST OF CATALYST PLUGINS
137 CREATE A CATALYST CONTROLLER
148 Create a Catalyst View Using TTSite
152 Globally Customize Every View
156 Create a TT Template Page
162 CREATE A SQLITE DATABASE
166 DATABASE ACCESS WITH DBIx::Class
172 Create a Dynamic DBIC Model
182 A STATIC DATABASE MODEL WITH DBIx::Class
188 Create Static DBIC Schema Files
192 Updating the Generated DBIC Schema Files
202 RUNNING THE APPLICATION FROM THE COMMAND LINE
212 Using RenderView for the Default View
216 Using The Default Template Name
220 Return To A Manually-Specified Template
227 =head2 L<Part 4: Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD>
239 Include a Create Action in the Books Controller
243 Include a Template for the url_create Action:
247 Try the url_create Feature
253 MANUALLY BUILDING A CREATE FORM
259 Add a Method to Display the Form
263 Add a Template for the Form
267 Add Method to Process Form Values and Update Database
277 A SIMPLE DELETE FEATURE
283 Include a Delete Link in the List
287 Add a Delete Action to the Controller
291 Try the Delete Feature
295 Fixing a Dangerous URL
299 Try the Delete and Redirect Logic
303 Using uri_for to Pass Query Parameters
307 Try the Delete and Redirect With Query Param Logic
314 =head2 L<Part 5: Authentication|Catalyst::Manual::Tutorial::Authentication>
326 Add Users and Roles to the Database
330 Add User and Role Information to DBIC Schema
334 Sanity-Check Reload of Development Server
338 Include Authentication and Session Plugins
342 Configure Authentication
346 Add Login and Logout Controllers
350 Add a Login Form TT Template Page
358 Displaying Content Only to Authenticated Users
362 Try Out Authentication
368 USING PASSWORD HASHES
374 Get a SHA-1 Hash for the Password
378 Switch to SHA-1 Password Hashes in the Database
382 Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
386 Try Out the Hashed Passwords
392 USING THE SESSION FOR FLASH
402 Switch To Flash-To-Stash
409 =head2 L<Part 6: Authorization|Catalyst::Manual::Tutorial::Authorization>
421 Update Plugins to Include Support for Authorization
425 Add Config Information for Authorization
429 Add Role-Specific Logic to the ``Book List'' Template
433 Limit Books::add to admin Users
437 Try Out Authentication And Authorization
443 ENABLE ACL-BASED AUTHORIZATION
449 Add the Catalyst::Plugin::Authorization::ACL Plugin
453 Add ACL Rules to the Application Class
457 Add a Method to Handle Access Violations
464 =head2 L<Part 7: Debugging|Catalyst::Manual::Tutorial::Debugging>
474 RUNNING CATALYST UNDER THE PERL DEBUGGER
478 DEBUGGING MODULES FROM CPAN
483 =head2 L<Part 8: Testing|Catalyst::Manual::Tutorial::Testing>
489 RUNNING THE "CANNED" CATALYST TESTS
493 RUNNING A SINGLE TEST
497 ADDING YOUR OWN TEST SCRIPT
501 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
506 =head2 L<Part 9: Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
512 ADVANCED CRUD OPTIONS
517 =head2 L<Part 10: Appendices|Catalyst::Manual::Tutorial::Appendices>
523 APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
529 "Un-indenting" with Vi/Vim
533 "Un-indenting" with Emacs
539 APPENDIX 2: USING MYSQL AND POSTGRESQL
555 APPENDIX 3: IMPROVED HASHING SCRIPT
562 This tutorial would not have been possible without the input of many
563 different people in the Catalyst community. In particular, the
564 primary author would like to thank:
570 Sebastian Riedel for founding the Catalyst project.
574 The members of the Catalyst Core Team for their tireless efforts to
575 advance the Catalyst project. Although all of the Core Team members
576 have played a key role in this tutorial, it would have never been
577 possible without the critical contributions of: Matt Trout, for his
578 unfathomable knowledge of all things Perl and Catalyst (and his
579 willingness to answer lots of my questions); Jesse Sheidlower, for his
580 incredible skill with the written word and dedication to improving the
581 Catalyst documentation; and Yuval Kogman, for his work on the Catalyst
582 "Auth & Authz" plugins (the original focus of the tutorial) and other
583 key Catalyst modules.
587 Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
588 and Jess Robinson (including their work on the original Catalyst
593 Kieren Diment for his oversite of Catalyst-related documentation.
597 Everyone on #catalyst and #catalyst-dev.
601 Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the
602 PostgreSQL content in the Appendix.
606 People who have emailed me with corrections and suggestions on the
607 tutorial. As of the most recent release, this include: Florian Ragwitz,
608 Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno, Bryan
609 Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning Sprang, Jeremy
610 Jones, David Kurtz, Ingo Wichmann, and Shlomi Fish. Also, thanks to
611 Devin Austin for coming up with an initial version of a non-TTSite
612 wrapper page. I'm sure I am missing some names here... apologies for
613 that (please let me know if you name should be here).
619 Kennedy Clark, C<hkclark@gmail.com>
621 Please report any errors, issues or suggestions to the author. The
622 most recent version of the Catalyst Tutorial can be found at
623 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
625 Copyright 2006-2008, Kennedy Clark, under Creative Commons License
626 (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).