Commit | Line | Data |
83cea649 |
1 | =head1 NAME |
2 | |
4d583dd8 |
3 | Catalyst::Manual::Tutorial - Catalyst Tutorial: Overview |
4 | |
83cea649 |
5 | =head1 DESCRIPTION |
6 | |
64ccd8a8 |
7 | The Catalyst framework is a flexible and comprehensive environment for |
8 | quickly building high-functionality web applications. This tutorial is |
653f4595 |
9 | designed to provide a rapid introduction to its basics and its most |
10 | commonly used features while focusing on real-world best practices. |
4d583dd8 |
11 | |
653f4595 |
12 | The tutorial is divided into the following sections: |
4d583dd8 |
13 | |
14 | =over 4 |
15 | |
16 | =item * |
17 | |
653f4595 |
18 | L<Introduction|Catalyst::Manual::Tutorial::Intro> |
4d583dd8 |
19 | |
20 | =item * |
21 | |
653f4595 |
22 | L<Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics> |
4d583dd8 |
23 | |
24 | =item * |
25 | |
653f4595 |
26 | L<Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD> |
4d583dd8 |
27 | |
28 | =item * |
29 | |
653f4595 |
30 | L<Authentication|Catalyst::Manual::Tutorial::Authentication> |
4d583dd8 |
31 | |
32 | =item * |
33 | |
653f4595 |
34 | L<Authorization|Catalyst::Manual::Tutorial::Authorization> |
4d583dd8 |
35 | |
36 | =item * |
37 | |
653f4595 |
38 | L<Testing|Catalyst::Manual::Tutorial::Testing> |
4d583dd8 |
39 | |
40 | =item * |
41 | |
653f4595 |
42 | L<Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD> |
4d583dd8 |
43 | |
44 | =item * |
45 | |
653f4595 |
46 | L<Appendices|Catalyst::Manual::Tutorial::Appendices> |
4d583dd8 |
47 | |
48 | =back |
49 | |
64ccd8a8 |
50 | A tarball of the final application is available at |
dadc4d4f |
51 | L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz>. |
52 | |
4d583dd8 |
53 | |
54 | =head1 Detailed Table Of Contents |
55 | |
56 | =head2 Part 1: Introduction |
57 | |
58 | =over 4 |
59 | |
60 | =item * |
61 | |
62 | VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL |
63 | |
64 | =item * |
65 | |
66 | CATALYST INSTALLATION |
67 | |
68 | =item * |
69 | |
70 | DATABASES |
71 | |
72 | =item * |
73 | |
74 | WHERE TO GET WORKING CODE |
75 | |
76 | =back |
77 | |
78 | |
4d583dd8 |
79 | =head2 Part 2: Catalyst Application Development Basics |
80 | |
81 | =over 4 |
82 | |
83 | =item * |
84 | |
85 | CREATE A CATALYST PROJECT |
86 | |
87 | =item * |
88 | |
89 | CREATE A SQLITE DATABASE |
90 | |
91 | =item * |
92 | |
93 | EDIT THE LIST OF CATALYST PLUGINS |
94 | |
95 | =item * |
96 | |
97 | DATABASE ACCESS WITH DBIx::Class |
98 | |
642d4547 |
99 | |
100 | =over 4 |
101 | |
4d583dd8 |
102 | =item * |
103 | |
104 | Create a DBIC Schema File |
105 | |
106 | =item * |
107 | |
108 | Create the DBIC ``Result Source'' Files |
109 | |
110 | =item * |
111 | |
653f4595 |
112 | Use Catalyst::Model::DBIC::Schema to Load the Model Class |
4d583dd8 |
113 | |
642d4547 |
114 | =back |
115 | |
116 | |
117 | =item * |
4d583dd8 |
118 | |
119 | CREATE A CATALYST CONTROLLER |
120 | |
121 | =item * |
122 | |
123 | CATALYST VIEWS |
124 | |
642d4547 |
125 | |
4d583dd8 |
126 | =over 4 |
127 | |
128 | =item * |
129 | |
653f4595 |
130 | Create a Catalyst View Using TTSite |
4d583dd8 |
131 | |
132 | =item * |
133 | |
642d4547 |
134 | Using RenderView for the Default View |
135 | |
136 | =item * |
137 | |
4d583dd8 |
138 | Globally Customize Every View |
139 | |
140 | =item * |
141 | |
142 | Create a TT Template Page |
143 | |
144 | =back |
145 | |
642d4547 |
146 | |
4d583dd8 |
147 | =item * |
148 | |
149 | RUN THE APPLICATION |
150 | |
151 | =back |
152 | |
4d583dd8 |
153 | =head2 Part 3: Basic CRUD |
154 | |
155 | =over 4 |
156 | |
157 | =item * |
158 | |
159 | FORMLESS SUBMISSION |
160 | |
161 | =over 4 |
162 | |
163 | =item * |
164 | |
165 | Include a Create Action in the Books Controller |
166 | |
167 | =item * |
168 | |
169 | Include a Template for the url_create Action: |
170 | |
171 | =item * |
172 | |
173 | Try the url_create Feature |
174 | |
175 | =back |
176 | |
177 | =item * |
178 | |
179 | MANUALLY BUILDING A CREATE FORM |
180 | |
181 | =over 4 |
182 | |
183 | =item * |
184 | |
653f4595 |
185 | Add a Method to Display the Form |
4d583dd8 |
186 | |
187 | =item * |
188 | |
189 | Add a Template for the Form |
190 | |
191 | =item * |
192 | |
193 | Add Method to Process Form Values and Update Database |
194 | |
195 | =item * |
196 | |
653f4595 |
197 | Test Out the Form |
4d583dd8 |
198 | |
199 | =back |
200 | |
201 | =item * |
202 | |
203 | A SIMPLE DELETE FEATURE |
204 | |
205 | =over 4 |
206 | |
207 | =item * |
208 | |
209 | Include a Delete Link in the List |
210 | |
211 | =item * |
212 | |
213 | Add a Delete Action to the Controller |
214 | |
215 | =item * |
216 | |
217 | Try the Delete Feature |
218 | |
219 | =back |
220 | |
221 | =back |
222 | |
4d583dd8 |
223 | =head2 Part 4: Authentication |
224 | |
225 | =over 4 |
226 | |
227 | =item * |
228 | |
229 | BASIC AUTHENTICATION |
230 | |
231 | =over 4 |
232 | |
233 | =item * |
234 | |
235 | Add Users and Roles to the Database |
236 | |
237 | =item * |
238 | |
64ccd8a8 |
239 | Add User and Role Information to DBIC Schema |
4d583dd8 |
240 | |
241 | =item * |
242 | |
243 | Create New ``Result Source Objects'' |
244 | |
245 | =item * |
246 | |
247 | Sanity-Check Reload of Development Server |
248 | |
249 | =item * |
250 | |
251 | Include Authentication and Session Plugins |
252 | |
253 | =item * |
254 | |
255 | Configure Authentication |
256 | |
257 | =item * |
258 | |
259 | Add Login and Logout Controllers |
260 | |
261 | =item * |
262 | |
263 | Add a Login Form TT Template Page |
264 | |
265 | =item * |
266 | |
267 | Add Valid User Check |
268 | |
269 | =item * |
270 | |
271 | Displaying Content Only to Authenticated Users |
272 | |
273 | =item * |
274 | |
275 | Try Out Authentication |
276 | |
277 | =back |
278 | |
279 | =item * |
280 | |
281 | USING PASSWORD HASHES |
282 | |
283 | =over 4 |
284 | |
285 | =item * |
286 | |
287 | Get a SHA-1 Hash for the Password |
288 | |
289 | =item * |
290 | |
291 | Switch to SHA-1 Password Hashes in the Database |
292 | |
293 | =item * |
294 | |
295 | Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC |
296 | |
297 | =item * |
298 | |
299 | Try Out the Hashed Passwords |
300 | |
301 | =back |
302 | |
303 | =back |
304 | |
4d583dd8 |
305 | =head2 Part 5: Authorization |
306 | |
307 | =over 4 |
308 | |
309 | =item * |
83cea649 |
310 | |
4d583dd8 |
311 | BASIC AUTHORIZATION |
83cea649 |
312 | |
4d583dd8 |
313 | =over 4 |
83cea649 |
314 | |
4d583dd8 |
315 | =item * |
83cea649 |
316 | |
653f4595 |
317 | Update Plugins to Include Support for Authorization |
83cea649 |
318 | |
4d583dd8 |
319 | =item * |
83cea649 |
320 | |
4d583dd8 |
321 | Add Config Information for Authorization |
83cea649 |
322 | |
4d583dd8 |
323 | =item * |
83cea649 |
324 | |
4d583dd8 |
325 | Add Role-Specific Logic to the ``Book List'' Template |
b248fa4a |
326 | |
4d583dd8 |
327 | =item * |
83cea649 |
328 | |
4d583dd8 |
329 | Limit Books::add to admin Users |
83cea649 |
330 | |
4d583dd8 |
331 | =item * |
83cea649 |
332 | |
4d583dd8 |
333 | Try Out Authentication And Authorization |
83cea649 |
334 | |
4d583dd8 |
335 | =back |
b33ed88c |
336 | |
4d583dd8 |
337 | =item * |
b248fa4a |
338 | |
4d583dd8 |
339 | ENABLE ACL-BASED AUTHORIZATION |
b33ed88c |
340 | |
4d583dd8 |
341 | =over 4 |
b460ad78 |
342 | |
4d583dd8 |
343 | =item * |
83cea649 |
344 | |
4d583dd8 |
345 | Add the Catalyst::Plugin::Authorization::ACL Plugin |
b248fa4a |
346 | |
4d583dd8 |
347 | =item * |
83cea649 |
348 | |
4d583dd8 |
349 | Add ACL Rules to the Application Class |
83cea649 |
350 | |
4d583dd8 |
351 | =item * |
387e4c50 |
352 | |
4d583dd8 |
353 | Add a Method to Handle Access Violations |
83cea649 |
354 | |
4d583dd8 |
355 | =back |
83cea649 |
356 | |
4d583dd8 |
357 | =back |
83cea649 |
358 | |
4d583dd8 |
359 | =head2 Part 6: Debugging |
83cea649 |
360 | |
4d583dd8 |
361 | =over 4 |
83cea649 |
362 | |
4d583dd8 |
363 | =item * |
83cea649 |
364 | |
4d583dd8 |
365 | LOG STATEMENTS |
83cea649 |
366 | |
4d583dd8 |
367 | =item * |
83cea649 |
368 | |
4d583dd8 |
369 | RUNNING CATALYST UNDER THE PERL DEBUGGER |
83cea649 |
370 | |
642d4547 |
371 | =item * |
372 | |
373 | DEBUGGING MODULES FROM CPAN |
374 | |
4d583dd8 |
375 | =back |
587d5860 |
376 | |
4d583dd8 |
377 | =head2 Part 7: Testing |
83cea649 |
378 | |
4d583dd8 |
379 | =over 4 |
83cea649 |
380 | |
4d583dd8 |
381 | =item * |
8d47005f |
382 | |
4d583dd8 |
383 | RUNNING THE "CANNED" CATALYST TESTS |
8d47005f |
384 | |
4d583dd8 |
385 | =item * |
8d47005f |
386 | |
4d583dd8 |
387 | RUNNING A SINGLE TEST |
c425bfeb |
388 | |
4d583dd8 |
389 | =item * |
c425bfeb |
390 | |
4d583dd8 |
391 | ADDING YOUR OWN TEST SCRIPT |
8d47005f |
392 | |
4d583dd8 |
393 | =item * |
8d47005f |
394 | |
4d583dd8 |
395 | SUPPORTING BOTH PRODUCTION AND TEST DATABASES |
de6fb80a |
396 | |
4d583dd8 |
397 | =back |
8d47005f |
398 | |
4d583dd8 |
399 | =head2 Part 8: Advanced CRUD |
8d47005f |
400 | |
4d583dd8 |
401 | =over 4 |
8d47005f |
402 | |
4d583dd8 |
403 | =item * |
8d47005f |
404 | |
4d583dd8 |
405 | HTML::WIDGET FORM CREATION |
de6fb80a |
406 | |
4d583dd8 |
407 | =over 4 |
8d47005f |
408 | |
4d583dd8 |
409 | =item * |
8d47005f |
410 | |
4d583dd8 |
411 | Add the HTML::Widget Plugin |
8d47005f |
412 | |
4d583dd8 |
413 | =item * |
8d47005f |
414 | |
4d583dd8 |
415 | Add a Form Creation Helper Method |
8d47005f |
416 | |
4d583dd8 |
417 | =item * |
8d47005f |
418 | |
4d583dd8 |
419 | Add Actions to Display and Save the Form |
8d47005f |
420 | |
4d583dd8 |
421 | =item * |
b460ad78 |
422 | |
4d583dd8 |
423 | Update the CSS |
b460ad78 |
424 | |
4d583dd8 |
425 | =item * |
b460ad78 |
426 | |
4d583dd8 |
427 | Create a Template Page To Display The Form |
b460ad78 |
428 | |
4d583dd8 |
429 | =item * |
b460ad78 |
430 | |
4d583dd8 |
431 | Add Links for Create and Update via HTML::Widget |
b460ad78 |
432 | |
4d583dd8 |
433 | =item * |
b460ad78 |
434 | |
4d583dd8 |
435 | Test The <HTML::Widget> Create Form |
b460ad78 |
436 | |
4d583dd8 |
437 | =back |
b460ad78 |
438 | |
4d583dd8 |
439 | =item * |
b460ad78 |
440 | |
4d583dd8 |
441 | HTML::WIDGET VALIDATION AND FILTERING |
b460ad78 |
442 | |
4d583dd8 |
443 | =over 4 |
b460ad78 |
444 | |
4d583dd8 |
445 | =item * |
83cea649 |
446 | |
4d583dd8 |
447 | Add Constraints and Filters to the Widget Creation Method |
8d47005f |
448 | |
4d583dd8 |
449 | =item * |
8d47005f |
450 | |
4d583dd8 |
451 | Rebuild the Form Submission Method to Include Validation |
8d47005f |
452 | |
4d583dd8 |
453 | =item * |
8d47005f |
454 | |
4d583dd8 |
455 | Try Out the Form |
8d47005f |
456 | |
4d583dd8 |
457 | =back |
8d47005f |
458 | |
4d583dd8 |
459 | =item * |
8d47005f |
460 | |
4d583dd8 |
461 | Enable DBIx::Class::HTMLWidget Support |
8d47005f |
462 | |
4d583dd8 |
463 | =over 4 |
8d47005f |
464 | |
4d583dd8 |
465 | =item * |
83cea649 |
466 | |
4d583dd8 |
467 | Add DBIx::Class::HTMLWidget to DBIC Model |
b460ad78 |
468 | |
4d583dd8 |
469 | =item * |
b460ad78 |
470 | |
4d583dd8 |
471 | Use populate_from_widget in hw_create_do |
b460ad78 |
472 | |
4d583dd8 |
473 | =back |
b460ad78 |
474 | |
4d583dd8 |
475 | =back |
b460ad78 |
476 | |
4d583dd8 |
477 | =head2 Part 9: Appendices |
b460ad78 |
478 | |
4d583dd8 |
479 | =over 4 |
b460ad78 |
480 | |
4d583dd8 |
481 | =item * |
8d47005f |
482 | |
4d583dd8 |
483 | APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES |
8d47005f |
484 | |
4d583dd8 |
485 | =over 4 |
8d47005f |
486 | |
4d583dd8 |
487 | =item * |
8d47005f |
488 | |
4d583dd8 |
489 | "Un-indenting" with Vi/Vim |
8d47005f |
490 | |
4d583dd8 |
491 | =item * |
8d47005f |
492 | |
4d583dd8 |
493 | "Un-indenting" with Emacs |
8d47005f |
494 | |
4d583dd8 |
495 | =back |
8d47005f |
496 | |
4d583dd8 |
497 | =item * |
8d47005f |
498 | |
4d583dd8 |
499 | APPENDIX 2: USING MYSQL AND POSTGRESQL |
8d47005f |
500 | |
4d583dd8 |
501 | =over 4 |
8d47005f |
502 | |
4d583dd8 |
503 | =item * |
b460ad78 |
504 | |
4d583dd8 |
505 | MySQL |
8d47005f |
506 | |
4d583dd8 |
507 | =item * |
8d47005f |
508 | |
4d583dd8 |
509 | PostgreSQL |
8d47005f |
510 | |
4d583dd8 |
511 | =back |
b460ad78 |
512 | |
642d4547 |
513 | =item * |
514 | |
515 | APPENDIX 3: IMPROVED HASHING SCRIPT |
516 | |
4d583dd8 |
517 | =back |
83cea649 |
518 | |
642d4547 |
519 | |
520 | =head1 THANKS |
521 | |
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: |
525 | |
526 | =over 4 |
527 | |
528 | =item * |
529 | |
530 | Sebastian Riedel for founding the Catalyst project. |
531 | |
532 | =item * |
533 | |
f4260a7a |
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 |
642d4547 |
543 | key Catalyst modules. |
544 | |
545 | =item * |
546 | |
642d4547 |
547 | Other Catalyst documentation folks like Kieren Diment, Gavin Henry, |
548 | and Jess Robinson (including their work on the original Catalyst |
549 | tutorial). |
550 | |
551 | =item * |
552 | |
be9712b1 |
553 | Everyone on #catalyst and #catalyst-dev. |
554 | |
555 | =item * |
556 | |
642d4547 |
557 | People who have emailed me with corrections and suggestions on the |
558 | tutorial. As of the most recent release, this include: Florian Ragwitz, |
c9b77c06 |
559 | Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno, |
dadc4d4f |
560 | Bryan Roach, Ashley Berlin, David Kamholz, and Kevin Old. |
642d4547 |
561 | |
562 | =back |
563 | |
564 | |
565 | |
566 | =head1 AUTHOR |
567 | |
568 | Kennedy Clark, C<hkclark@gmail.com> |
569 | |
570 | Please report any errors, issues or suggestions to the author. The |
7d310f12 |
571 | most recent version of the Catalyst Tutorial can be found at |
642d4547 |
572 | L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>. |
573 | |
574 | Copyright 2006, Kennedy Clark, under Creative Commons License |
575 | (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>). |