1Catalyst::Manual::TutorUisaelr(3C)ontributed Perl DocumeCnattaatliyosnt::Manual::Tutorial(3)
2
3
4
6 Catalyst::Manual::Tutorial - Catalyst Tutorial: Overview
7
9 The Catalyst framework is a flexible and comprehensive environment for
10 quickly building high-functionality web applications. This tutorial is
11 designed to provide a rapid introduction to its basics and its most
12 commonly used features while focusing on real-world best practices.
13
14 We suggest that you read this introduction on the web. Make sure you
15 are reading the latest version of the tutorial by visiting
16 <https://metacpan.org/module/Catalyst::Manual::Tutorial>.
17 Alternatively you can use CPAN modules like Pod::Webserver,
18 Pod::POM::Web, Pod::Browser (Catalyst based), or CPAN::Mini::Webserver
19 to read a local copy of the tutorial.
20
21 The tutorial is divided into the following sections:
22
23 NOTE: CLICK THESE LINKS TO JUMP TO CHAPTERS (the index links above only
24 navigate inside this page).
25
26 1. Introduction
27
28 2. Catalyst Basics
29
30 3. More Catalyst Basics
31
32 4. Basic CRUD
33
34 5. Authentication
35
36 6. Authorization
37
38 7. Debugging
39
40 8. Testing
41
42 9. Advanced CRUD
43
44 10. Appendices
45
46 Final code tarballs for each chapter of the tutorial are available at
47 <http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/>.
48
50 Chapter 1: Intro
51 Note: Click on the heading in the previous line to jump to the actual
52 chapter. Below is a "table of contents" for this chapter.
53
54 · VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
55
56 · CATALYST INSTALLATION
57
58 · DATABASES
59
60 · WHERE TO GET WORKING CODE
61
62 Chapter 2: Catalyst Basics
63 Note: Click on the heading in the previous line to jump to the actual
64 chapter. Below is a "table of contents" for this chapter.
65
66 · CREATE A CATALYST PROJECT
67
68 · HELLO WORLD
69
70 · The Simplest Way
71
72 · Hello, World! Using a View and a Template
73
74 · CREATE A SIMPLE CONTROLLER AND AN ACTION
75
76 Chapter 3: More Catalyst Basics
77 Note: Click on the heading in the previous line to jump to the actual
78 chapter. Below is a "table of contents" for this chapter.
79
80 · CREATE A NEW APPLICATION
81
82 · EDIT THE LIST OF CATALYST PLUGINS
83
84 · CREATE A CATALYST CONTROLLER
85
86 · CATALYST VIEWS
87
88 · Create a Catalyst View
89
90 · Create a TT Template Page
91
92 · Test Run The Application
93
94 · CREATE A SQLITE DATABASE
95
96 · DATABASE ACCESS WITH DBIx::Class
97
98 · Create a Dynamic DBIC Model
99
100 · ENABLE THE MODEL IN THE CONTROLLER
101
102 · Test Run The Application
103
104 · CREATE A WRAPPER FOR THE VIEW
105
106 · Configure TT.pm For The Wrapper
107
108 · Create the Wrapper Template File and Stylesheet
109
110 · Test Run The Application
111
112 · A STATIC DATABASE MODEL WITH DBIx::Class
113
114 · Create Static DBIC Schema Files
115
116 · Updating the Generated DBIC Schema Files
117
118 · Run The Application
119
120 · UPDATING THE VIEW
121
122 · RUNNING THE APPLICATION FROM THE COMMAND LINE
123
124 · OPTIONAL INFORMATION
125
126 · Using RenderView for the Default View
127
128 · Using The Default Template Name
129
130 · Return To A Manually-Specified Template
131
132 Chapter 4: Basic CRUD
133 Note: Click on the heading in the previous line to jump to the actual
134 chapter. Below is a "table of contents" for this chapter.
135
136 · FORMLESS SUBMISSION
137
138 · Include a Create Action in the Books Controller
139
140 · Include a Template for the url_create Action:
141
142 · Try the url_create Feature
143
144 · CONVERT TO A CHAINED ACTION
145
146 · Try the Chained Action
147
148 · Refactor to Use a "Base" Method to Start the Chains
149
150 · MANUALLY BUILDING A CREATE FORM
151
152 · Add a Method to Display the Form
153
154 · Add a Template for the Form
155
156 · Add Method to Process Form Values and Update Database
157
158 · Test Out the Form
159
160 · A SIMPLE DELETE FEATURE
161
162 · Include a Delete Link in the List
163
164 · Add a Common Method to Retrieve a Book for the Chain
165
166 · Add a Delete Action to the Controller
167
168 · Try the Delete Feature
169
170 · Fixing a Dangerous URL
171
172 · Try the Delete and Redirect Logic
173
174 · Using uri_for to Pass Query Parameters
175
176 · Try the Delete and Redirect With Query Param Logic
177
178 · EXPLORING THE POWER OF DBIC
179
180 · Add Datetime Columns to Our Existing Books Table
181
182 · Update DBIC to Automatically Handle the Datetime Columns
183
184 · Create a ResultSet Class
185
186 · Chaining ResultSets
187
188 · Adding Methods to Result Classes
189
190 Chapter 5: Authentication
191 Note: Click on the heading in the previous line to jump to the actual
192 chapter. Below is a "table of contents" for this chapter.
193
194 · BASIC AUTHENTICATION
195
196 · Add Users and Roles to the Database
197
198 · Add User and Role Information to DBIC Schema
199
200 · Sanity-Check Reload of Development Server
201
202 · Include Authentication and Session Plugins
203
204 · Configure Authentication
205
206 · Add Login and Logout Controllers
207
208 · Add a Login Form TT Template Page
209
210 · Add Valid User Check
211
212 · Displaying Content Only to Authenticated Users
213
214 · Try Out Authentication
215
216 · USING PASSWORD HASHES
217
218 · Get a SHA-1 Hash for the Password
219
220 · Switch to SHA-1 Password Hashes in the Database
221
222 · Enable SHA-1 Hash Passwords in
223 Catalyst::Plugin::Authentication::Store::DBIC
224
225 · Try Out the Hashed Passwords
226
227 · USING THE SESSION FOR FLASH
228
229 · Try Out Flash
230
231 · Switch To Flash-To-Stash
232
233 Chapter 6: Authorization
234 Note: Click on the heading in the previous line to jump to the actual
235 chapter. Below is a "table of contents" for this chapter.
236
237 · BASIC AUTHORIZATION
238
239 · Update Plugins to Include Support for Authorization
240
241 · Add Config Information for Authorization
242
243 · Add Role-Specific Logic to the ``Book List'' Template
244
245 · Limit Books::add to admin Users
246
247 · Try Out Authentication And Authorization
248
249 · ENABLE MODEL-BASED AUTHORIZATION
250
251 Chapter 7: Debugging
252 Note: Click on the heading in the previous line to jump to the actual
253 chapter. Below is a "table of contents" for this chapter.
254
255 · LOG STATEMENTS
256
257 · RUNNING CATALYST UNDER THE PERL DEBUGGER
258
259 · DEBUGGING MODULES FROM CPAN
260
261 · TT DEBUGGING
262
263 Chapter 8: Testing
264 Note: Click on the heading in the previous line to jump to the actual
265 chapter. Below is a "table of contents" for this chapter.
266
267 · RUNNING THE "CANNED" CATALYST TESTS
268
269 · RUNNING A SINGLE TEST
270
271 · ADDING YOUR OWN TEST SCRIPT
272
273 · SUPPORTING BOTH PRODUCTION AND TEST DATABASES
274
275 Chapter 9: Advanced CRUD
276 Note: Click on the heading in the previous line to jump to the actual
277 chapter. Below is a "table of contents" for this chapter.
278
279 · ADVANCED CRUD OPTIONS
280
281 Chapter 10: Appendices
282 Note: Click on the heading in the previous line to jump to the actual
283 chapter. Below is a "table of contents" for this chapter.
284
285 · APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES
286
287 · "Un-indenting" with Vi/Vim
288
289 · "Un-indenting" with Emacs
290
291 · APPENDIX 2: USING MYSQL AND POSTGRESQL
292
293 · MySQL
294
295 · PostgreSQL
296
297 · APPENDIX 3: IMPROVED HASHING SCRIPT
298
300 This tutorial would not have been possible without the input of many
301 different people in the Catalyst community. In particular, the primary
302 author would like to thank:
303
304 · Sebastian Riedel for founding the Catalyst project.
305
306 · The members of the Catalyst Core Team for their tireless efforts to
307 advance the Catalyst project. Although all of the Core Team
308 members have played a key role in this tutorial, it would have
309 never been possible without the critical contributions of: Matt
310 Trout, for his unfathomable knowledge of all things Perl and
311 Catalyst (and his willingness to answer lots of my questions);
312 Jesse Sheidlower, for his incredible skill with the written word
313 and dedication to improving the Catalyst documentation; and Yuval
314 Kogman, for his work on the Catalyst "Auth & Authz" plugins (the
315 original focus of the tutorial) and other key Catalyst modules.
316
317 · Other Catalyst documentation folks like Kieren Diment, Gavin Henry,
318 and Jess Robinson (including their work on the original Catalyst
319 tutorial).
320
321 · Kieren Diment for his oversight of Catalyst-related documentation.
322
323 · Everyone on #catalyst and #catalyst-dev.
324
325 · Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the
326 PostgreSQL content in the Appendix.
327
328 · People who have emailed me with corrections and suggestions on the
329 tutorial. As of the most recent release, this include: Florian
330 Ragwitz, Mauro Andreolini, Jim Howard, Giovanni Gigante, William
331 Moreno, Bryan Roach, Ashley Berlin, David Kamholz, Kevin Old,
332 Henning Sprang, Jeremy Jones, David Kurtz, Ingo Wichmann, Shlomi
333 Fish, Murray Walker, Adam Witney and xenoterracide (Caleb Cushing).
334 Thanks to Devin Austin for coming up with an initial version of a
335 non-TTSite wrapper page. Also, a huge thank you to Kiffin Gish for
336 all the hard work on the "database depluralization" effort and
337 Rafael Kitover for the work on updating the tutorial to include
338 foreign key support for SQLite. I'm sure I am missing some names
339 here... apologies for that (please let me know if you name should
340 be here).
341
343 Kennedy Clark, "hkclark@gmail.com"
344
345 Feel free to contact the author for any errors or suggestions, but the
346 best way to report issues is via the CPAN RT Bug system at
347 <https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Manual>.
348
349 Copyright 2006-2010, Kennedy Clark, under the Creative Commons
350 Attribution Share-Alike License Version 3.0
351 (<http://creativecommons.org/licenses/by-sa/3.0/us/>).
352
353
354
355perl v5.28.1 2014-12-13 Catalyst::Manual::Tutorial(3)