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