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 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz>.
54 =head1 Detailed Table Of Contents
56 =head2 Part 1: Introduction
62 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
74 WHERE TO GET WORKING CODE
79 =head2 Part 2: Catalyst Application Development Basics
85 CREATE A CATALYST PROJECT
89 CREATE A SQLITE DATABASE
93 EDIT THE LIST OF CATALYST PLUGINS
97 DATABASE ACCESS WITH DBIx::Class
104 Create a DBIC Schema File
108 Create the DBIC ``Result Source'' Files
112 Use Catalyst::Model::DBIC::Schema to Load the Model Class
119 CREATE A CATALYST CONTROLLER
130 Create a Catalyst View Using TTSite
134 Using RenderView for the Default View
138 Globally Customize Every View
142 Create a TT Template Page
153 =head2 Part 3: Basic CRUD
165 Include a Create Action in the Books Controller
169 Include a Template for the url_create Action:
173 Try the url_create Feature
179 MANUALLY BUILDING A CREATE FORM
185 Add a Method to Display the Form
189 Add a Template for the Form
193 Add Method to Process Form Values and Update Database
203 A SIMPLE DELETE FEATURE
209 Include a Delete Link in the List
213 Add a Delete Action to the Controller
217 Try the Delete Feature
223 =head2 Part 4: Authentication
235 Add Users and Roles to the Database
239 Add User and Role Information to DBIC Schema
243 Create New ``Result Source Objects''
247 Sanity-Check Reload of Development Server
251 Include Authentication and Session Plugins
255 Configure Authentication
259 Add Login and Logout Controllers
263 Add a Login Form TT Template Page
271 Displaying Content Only to Authenticated Users
275 Try Out Authentication
281 USING PASSWORD HASHES
287 Get a SHA-1 Hash for the Password
291 Switch to SHA-1 Password Hashes in the Database
295 Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC
299 Try Out the Hashed Passwords
305 =head2 Part 5: Authorization
317 Update Plugins to Include Support for Authorization
321 Add Config Information for Authorization
325 Add Role-Specific Logic to the ``Book List'' Template
329 Limit Books::add to admin Users
333 Try Out Authentication And Authorization
339 ENABLE ACL-BASED AUTHORIZATION
345 Add the Catalyst::Plugin::Authorization::ACL Plugin
349 Add ACL Rules to the Application Class
353 Add a Method to Handle Access Violations
359 =head2 Part 6: Debugging
369 RUNNING CATALYST UNDER THE PERL DEBUGGER
373 DEBUGGING MODULES FROM CPAN
377 =head2 Part 7: Testing
383 RUNNING THE "CANNED" CATALYST TESTS
387 RUNNING A SINGLE TEST
391 ADDING YOUR OWN TEST SCRIPT
395 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
399 =head2 Part 8: Advanced CRUD
405 HTML::WIDGET FORM CREATION
411 Add the HTML::Widget Plugin
415 Add a Form Creation Helper Method
419 Add Actions to Display and Save the Form
427 Create a Template Page To Display The Form
431 Add Links for Create and Update via HTML::Widget
435 Test The <HTML::Widget> Create Form
441 HTML::WIDGET VALIDATION AND FILTERING
447 Add Constraints and Filters to the Widget Creation Method
451 Rebuild the Form Submission Method to Include Validation
461 Enable DBIx::Class::HTMLWidget Support
467 Add DBIx::Class::HTMLWidget to DBIC Model
471 Use populate_from_widget in hw_create_do
477 =head2 Part 9: Appendices
483 APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
489 "Un-indenting" with Vi/Vim
493 "Un-indenting" with Emacs
499 APPENDIX 2: USING MYSQL AND POSTGRESQL
515 APPENDIX 3: IMPROVED HASHING SCRIPT
522 This tutorial would not have been possible without the input of many
523 different people in the Catalyst community. In particular, the
524 primary author would like to thank:
530 Sebastian Riedel for founding the Catalyst project.
534 The members of the Catalyst Core Team for their tireless efforts to
535 advance the Catalyst project. Although all of the Core Team members
536 have played a key role in this tutorial, it would have never been
537 possible without the critical contributions of: Matt Trout, for his
538 unfathomable knowledge of all things Perl and Catalyst (and his
539 willingness to answer lots of my questions); Jesse Sheidlower, for his
540 incredible skill with the written word and dedication to improving the
541 Catalyst documentation; and Yuval Kogman, for his work on the Catalyst
542 "Auth & Authz" plugins (the original focus of the tutorial) and other
543 key Catalyst modules.
547 Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
548 and Jess Robinson (including their work on the original Catalyst
553 Everyone on #catalyst and #catalyst-dev.
557 People who have emailed me with corrections and suggestions on the
558 tutorial. As of the most recent release, this include: Florian Ragwitz,
559 Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno,
560 Bryan Roach, Ashley Berlin, David Kamholz, and Kevin Old.
568 Kennedy Clark, C<hkclark@gmail.com>
570 Please report any errors, issues or suggestions to the author. The
571 most recent version of the Catalyst Tutorial can be found at
572 L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
574 Copyright 2006, Kennedy Clark, under Creative Commons License
575 (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).