Commit | Line | Data |
5e602627 |
1 | =head1 NAME |
2 | |
3 | Catalyst::Manual::Tutorial - Catalyst Tutorial: Overview |
4 | |
5 | =head1 DESCRIPTION |
6 | |
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. |
11 | |
276c4698 |
12 | We suggest that you read this introduction on the web. Make sure you are |
13 | reading the latest version of the tutorial by visiting |
14 | L<http://search.cpan.org/perldoc?Catalyst::Manual::Tutorial>. Alternatively |
15 | you can use CPAN modules like L<Pod::Webserver>, L<Pod::POM::Web>, |
16 | L<Pod::Browser> (Catalyst based), or L<CPAN::Mini::Webserver> to read a local |
17 | copy of the tutorial. |
18 | |
5e602627 |
19 | The tutorial is divided into the following sections: |
20 | |
1435672d |
21 | B<NOTE: CLICK THESE LINKS TO JUMP TO CHAPTERS> (the index links above |
5e602627 |
22 | only navigate inside this page). |
23 | |
24 | =over 4 |
25 | |
3533daff |
26 | =item 1 |
5e602627 |
27 | |
1c96f145 |
28 | L<Introduction|Catalyst::Manual::Tutorial::01_Intro> |
5e602627 |
29 | |
3533daff |
30 | =item 2 |
5e602627 |
31 | |
1c96f145 |
32 | L<Catalyst Basics|Catalyst::Manual::Tutorial::02_CatalystBasics> |
5e602627 |
33 | |
3533daff |
34 | =item 3 |
35 | |
1c96f145 |
36 | L<More Catalyst Basics|Catalyst::Manual::Tutorial::03_MoreCatalystBasics> |
3533daff |
37 | |
38 | =item 4 |
5e602627 |
39 | |
1c96f145 |
40 | L<Basic CRUD|Catalyst::Manual::Tutorial::04_BasicCRUD> |
5e602627 |
41 | |
3533daff |
42 | =item 5 |
5e602627 |
43 | |
1c96f145 |
44 | L<Authentication|Catalyst::Manual::Tutorial::05_Authentication> |
5e602627 |
45 | |
3533daff |
46 | =item 6 |
5e602627 |
47 | |
1c96f145 |
48 | L<Authorization|Catalyst::Manual::Tutorial::06_Authorization> |
5e602627 |
49 | |
3533daff |
50 | =item 7 |
5e602627 |
51 | |
1c96f145 |
52 | L<Debugging|Catalyst::Manual::Tutorial::07_Debugging> |
5e602627 |
53 | |
3533daff |
54 | =item 8 |
5e602627 |
55 | |
1c96f145 |
56 | L<Testing|Catalyst::Manual::Tutorial::08_Testing> |
5e602627 |
57 | |
3533daff |
58 | =item 9 |
5e602627 |
59 | |
1c96f145 |
60 | L<Advanced CRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD> |
5e602627 |
61 | |
3533daff |
62 | =item 10 |
5e602627 |
63 | |
1c96f145 |
64 | L<Appendices|Catalyst::Manual::Tutorial::10_Appendices> |
5e602627 |
65 | |
66 | =back |
67 | |
4b4d3884 |
68 | Final code tarballs for each chapter of the tutorial are available at |
028b4e1a |
69 | L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/>. |
5e602627 |
70 | |
71 | |
72 | =head1 Detailed Table of Contents |
73 | |
3533daff |
74 | |
1c96f145 |
75 | =head2 L<Chapter 1: Intro|Catalyst::Manual::Tutorial::01_Intro> |
4b4d3884 |
76 | |
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. |
5e602627 |
79 | |
80 | =over 4 |
81 | |
82 | =item * |
83 | |
84 | VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL |
85 | |
86 | =item * |
87 | |
88 | CATALYST INSTALLATION |
89 | |
90 | =item * |
91 | |
92 | DATABASES |
93 | |
94 | =item * |
95 | |
96 | WHERE TO GET WORKING CODE |
97 | |
98 | =back |
99 | |
100 | |
1c96f145 |
101 | =head2 L<Chapter 2: Catalyst Basics|Catalyst::Manual::Tutorial::02_CatalystBasics> |
4b4d3884 |
102 | |
103 | Note: Click on the heading in the previous line to jump to the actual |
104 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
105 | |
106 | =over 4 |
107 | |
108 | =item * |
109 | |
110 | CREATE A CATALYST PROJECT |
111 | |
112 | =item * |
113 | |
3533daff |
114 | HELLO WORLD |
115 | |
116 | =over 4 |
5e602627 |
117 | |
118 | =item * |
119 | |
3533daff |
120 | The Simplest Way |
5e602627 |
121 | |
122 | =item * |
123 | |
3533daff |
124 | Hello, World! Using a View and a Template |
5e602627 |
125 | |
3533daff |
126 | =back |
5e602627 |
127 | |
128 | =item * |
129 | |
3533daff |
130 | CREATE A SIMPLE CONTROLLER AND AN ACTION |
131 | |
132 | =back |
5e602627 |
133 | |
5e602627 |
134 | |
1c96f145 |
135 | =head2 L<Chapter 3: More Catalyst Basics|Catalyst::Manual::Tutorial::03_MoreCatalystBasics> |
3533daff |
136 | |
4b4d3884 |
137 | Note: Click on the heading in the previous line to jump to the actual |
138 | chapter. Below is a "table of contents" for this chapter. |
3533daff |
139 | |
140 | =over 4 |
5e602627 |
141 | |
142 | =item * |
143 | |
3533daff |
144 | CREATE A NEW APPLICATION |
5e602627 |
145 | |
3533daff |
146 | =item * |
5e602627 |
147 | |
3533daff |
148 | EDIT THE LIST OF CATALYST PLUGINS |
5e602627 |
149 | |
150 | =item * |
151 | |
152 | CREATE A CATALYST CONTROLLER |
153 | |
154 | =item * |
155 | |
156 | CATALYST VIEWS |
157 | |
158 | |
159 | =over 4 |
160 | |
161 | =item * |
162 | |
4ab6212d |
163 | Create a Catalyst View |
5e602627 |
164 | |
165 | =item * |
166 | |
4ab6212d |
167 | Create a TT Template Page |
5e602627 |
168 | |
169 | =item * |
170 | |
4ab6212d |
171 | Test Run The Application |
3533daff |
172 | |
173 | =back |
5e602627 |
174 | |
175 | =item * |
176 | |
3533daff |
177 | CREATE A SQLITE DATABASE |
178 | |
179 | =item * |
180 | |
181 | DATABASE ACCESS WITH DBIx::Class |
182 | |
183 | =over 4 |
184 | |
185 | =item * |
186 | |
187 | Create a Dynamic DBIC Model |
5e602627 |
188 | |
189 | =back |
190 | |
3533daff |
191 | =item * |
192 | |
4ab6212d |
193 | ENABLE THE MODEL IN THE CONTROLLER |
194 | |
195 | =over 4 |
196 | |
197 | =item * |
198 | |
199 | Test Run The Application |
200 | |
201 | =back |
202 | |
203 | =item * |
204 | |
205 | CREATE A WRAPPER FOR THE VIEW |
206 | |
207 | =over 4 |
208 | |
209 | =item * |
210 | |
211 | Configure TT.pm For The Wrapper |
212 | |
213 | =item * |
214 | |
215 | Create the Wrapper Template File and Stylesheet |
216 | |
217 | =item * |
218 | |
219 | Test Run The Application |
220 | |
221 | =back |
3533daff |
222 | |
223 | =item * |
224 | |
225 | A STATIC DATABASE MODEL WITH DBIx::Class |
226 | |
227 | =over 4 |
228 | |
229 | =item * |
230 | |
231 | Create Static DBIC Schema Files |
232 | |
233 | =item * |
234 | |
235 | Updating the Generated DBIC Schema Files |
236 | |
4ab6212d |
237 | =item * |
238 | |
239 | Run The Application |
240 | |
3533daff |
241 | =back |
5e602627 |
242 | |
243 | =item * |
244 | |
4ab6212d |
245 | UPDATING THE VIEW |
5e602627 |
246 | |
247 | =item * |
248 | |
3533daff |
249 | RUNNING THE APPLICATION FROM THE COMMAND LINE |
250 | |
251 | =item * |
252 | |
4ab6212d |
253 | OPTIONAL INFORMATION |
3533daff |
254 | |
255 | =over 4 |
256 | |
257 | =item * |
258 | |
259 | Using RenderView for the Default View |
260 | |
261 | =item * |
262 | |
263 | Using The Default Template Name |
264 | |
265 | =item * |
266 | |
267 | Return To A Manually-Specified Template |
268 | |
269 | =back |
5e602627 |
270 | |
271 | =back |
272 | |
3533daff |
273 | |
1c96f145 |
274 | =head2 L<Chapter 4: Basic CRUD|Catalyst::Manual::Tutorial::04_BasicCRUD> |
4b4d3884 |
275 | |
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. |
5e602627 |
278 | |
279 | =over 4 |
280 | |
281 | =item * |
282 | |
283 | FORMLESS SUBMISSION |
284 | |
285 | =over 4 |
286 | |
287 | =item * |
288 | |
289 | Include a Create Action in the Books Controller |
290 | |
291 | =item * |
292 | |
293 | Include a Template for the url_create Action: |
294 | |
295 | =item * |
296 | |
297 | Try the url_create Feature |
298 | |
299 | =back |
300 | |
301 | =item * |
302 | |
4ab6212d |
303 | CONVERT TO A CHAINED ACTION |
304 | |
305 | =over 4 |
306 | |
307 | =item * |
308 | |
309 | Try the Chained Action |
310 | |
311 | =item * |
312 | |
313 | Refactor to Use a "Base" Method to Start the Chains |
314 | |
315 | =back |
316 | |
317 | =item * |
318 | |
5e602627 |
319 | MANUALLY BUILDING A CREATE FORM |
320 | |
321 | =over 4 |
322 | |
323 | =item * |
324 | |
325 | Add a Method to Display the Form |
326 | |
327 | =item * |
328 | |
329 | Add a Template for the Form |
330 | |
331 | =item * |
332 | |
333 | Add Method to Process Form Values and Update Database |
334 | |
335 | =item * |
336 | |
337 | Test Out the Form |
338 | |
339 | =back |
340 | |
341 | =item * |
342 | |
343 | A SIMPLE DELETE FEATURE |
344 | |
345 | =over 4 |
346 | |
347 | =item * |
348 | |
349 | Include a Delete Link in the List |
350 | |
351 | =item * |
352 | |
4ab6212d |
353 | Add a Common Method to Retrieve a Book for the Chain |
354 | |
355 | =item * |
356 | |
5e602627 |
357 | Add a Delete Action to the Controller |
358 | |
359 | =item * |
360 | |
361 | Try the Delete Feature |
362 | |
3533daff |
363 | =item * |
364 | |
365 | Fixing a Dangerous URL |
366 | |
367 | =item * |
368 | |
369 | Try the Delete and Redirect Logic |
370 | |
371 | =item * |
372 | |
373 | Using uri_for to Pass Query Parameters |
374 | |
375 | =item * |
376 | |
377 | Try the Delete and Redirect With Query Param Logic |
378 | |
5e602627 |
379 | =back |
380 | |
4ab6212d |
381 | =item * |
382 | |
383 | EXPLORING THE POWER OF DBIC |
384 | |
385 | =over 4 |
386 | |
387 | =item * |
388 | |
389 | Add Datetime Columns to Our Existing Books Table |
390 | |
391 | =item * |
392 | |
393 | Update DBIC to Automatically Handle the Datetime Columns |
394 | |
395 | =item * |
396 | |
397 | Create a ResultSet Class |
398 | |
399 | =item * |
400 | |
401 | Chaining ResultSets |
402 | |
403 | =item * |
404 | |
405 | Adding Methods to Result Classes |
406 | |
407 | =back |
408 | |
5e602627 |
409 | =back |
410 | |
3533daff |
411 | |
1c96f145 |
412 | =head2 L<Chapter 5: Authentication|Catalyst::Manual::Tutorial::05_Authentication> |
4b4d3884 |
413 | |
414 | Note: Click on the heading in the previous line to jump to the actual |
415 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
416 | |
417 | =over 4 |
418 | |
419 | =item * |
420 | |
421 | BASIC AUTHENTICATION |
422 | |
423 | =over 4 |
424 | |
425 | =item * |
426 | |
427 | Add Users and Roles to the Database |
428 | |
429 | =item * |
430 | |
431 | Add User and Role Information to DBIC Schema |
432 | |
433 | =item * |
434 | |
5e602627 |
435 | Sanity-Check Reload of Development Server |
436 | |
437 | =item * |
438 | |
439 | Include Authentication and Session Plugins |
440 | |
441 | =item * |
442 | |
443 | Configure Authentication |
444 | |
445 | =item * |
446 | |
447 | Add Login and Logout Controllers |
448 | |
449 | =item * |
450 | |
451 | Add a Login Form TT Template Page |
452 | |
453 | =item * |
454 | |
455 | Add Valid User Check |
456 | |
457 | =item * |
458 | |
459 | Displaying Content Only to Authenticated Users |
460 | |
461 | =item * |
462 | |
463 | Try Out Authentication |
464 | |
465 | =back |
466 | |
467 | =item * |
468 | |
469 | USING PASSWORD HASHES |
470 | |
471 | =over 4 |
472 | |
473 | =item * |
474 | |
475 | Get a SHA-1 Hash for the Password |
476 | |
477 | =item * |
478 | |
479 | Switch to SHA-1 Password Hashes in the Database |
480 | |
481 | =item * |
482 | |
483 | Enable SHA-1 Hash Passwords in Catalyst::Plugin::Authentication::Store::DBIC |
484 | |
485 | =item * |
486 | |
487 | Try Out the Hashed Passwords |
488 | |
489 | =back |
490 | |
3533daff |
491 | =item * |
492 | |
493 | USING THE SESSION FOR FLASH |
494 | |
495 | =over 4 |
496 | |
497 | =item * |
498 | |
499 | Try Out Flash |
500 | |
501 | =item * |
502 | |
503 | Switch To Flash-To-Stash |
504 | |
5e602627 |
505 | =back |
506 | |
3533daff |
507 | =back |
508 | |
509 | |
1c96f145 |
510 | =head2 L<Chapter 6: Authorization|Catalyst::Manual::Tutorial::06_Authorization> |
4b4d3884 |
511 | |
512 | Note: Click on the heading in the previous line to jump to the actual |
513 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
514 | |
515 | =over 4 |
516 | |
517 | =item * |
518 | |
519 | BASIC AUTHORIZATION |
520 | |
521 | =over 4 |
522 | |
523 | =item * |
524 | |
525 | Update Plugins to Include Support for Authorization |
526 | |
527 | =item * |
528 | |
529 | Add Config Information for Authorization |
530 | |
531 | =item * |
532 | |
533 | Add Role-Specific Logic to the ``Book List'' Template |
534 | |
535 | =item * |
536 | |
537 | Limit Books::add to admin Users |
538 | |
539 | =item * |
540 | |
541 | Try Out Authentication And Authorization |
542 | |
543 | =back |
544 | |
545 | =item * |
546 | |
4ab6212d |
547 | ENABLE MODEL-BASED AUTHORIZATION |
5e602627 |
548 | |
549 | =back |
550 | |
3533daff |
551 | |
1c96f145 |
552 | =head2 L<Chapter 7: Debugging|Catalyst::Manual::Tutorial::07_Debugging> |
4b4d3884 |
553 | |
554 | Note: Click on the heading in the previous line to jump to the actual |
555 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
556 | |
557 | =over 4 |
558 | |
559 | =item * |
560 | |
561 | LOG STATEMENTS |
562 | |
563 | =item * |
564 | |
565 | RUNNING CATALYST UNDER THE PERL DEBUGGER |
566 | |
567 | =item * |
568 | |
569 | DEBUGGING MODULES FROM CPAN |
570 | |
4ab6212d |
571 | =item * |
572 | |
573 | TT DEBUGGING |
574 | |
5e602627 |
575 | =back |
576 | |
3533daff |
577 | |
1c96f145 |
578 | =head2 L<Chapter 8: Testing|Catalyst::Manual::Tutorial::08_Testing> |
4b4d3884 |
579 | |
580 | Note: Click on the heading in the previous line to jump to the actual |
581 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
582 | |
583 | =over 4 |
584 | |
585 | =item * |
586 | |
587 | RUNNING THE "CANNED" CATALYST TESTS |
588 | |
589 | =item * |
590 | |
591 | RUNNING A SINGLE TEST |
592 | |
593 | =item * |
594 | |
595 | ADDING YOUR OWN TEST SCRIPT |
596 | |
597 | =item * |
598 | |
599 | SUPPORTING BOTH PRODUCTION AND TEST DATABASES |
600 | |
601 | =back |
602 | |
5e602627 |
603 | |
1c96f145 |
604 | =head2 L<Chapter 9: Advanced CRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD> |
4b4d3884 |
605 | |
606 | Note: Click on the heading in the previous line to jump to the actual |
607 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
608 | |
609 | =over 4 |
610 | |
611 | =item * |
612 | |
3533daff |
613 | ADVANCED CRUD OPTIONS |
5e602627 |
614 | |
615 | =back |
616 | |
5e602627 |
617 | |
1c96f145 |
618 | =head2 L<Chapter 10: Appendices|Catalyst::Manual::Tutorial::10_Appendices> |
4b4d3884 |
619 | |
620 | Note: Click on the heading in the previous line to jump to the actual |
621 | chapter. Below is a "table of contents" for this chapter. |
5e602627 |
622 | |
623 | =over 4 |
624 | |
625 | =item * |
626 | |
627 | APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES |
628 | |
629 | =over 4 |
630 | |
631 | =item * |
632 | |
633 | "Un-indenting" with Vi/Vim |
634 | |
635 | =item * |
636 | |
637 | "Un-indenting" with Emacs |
638 | |
639 | =back |
640 | |
641 | =item * |
642 | |
643 | APPENDIX 2: USING MYSQL AND POSTGRESQL |
644 | |
645 | =over 4 |
646 | |
647 | =item * |
648 | |
649 | MySQL |
650 | |
651 | =item * |
652 | |
653 | PostgreSQL |
654 | |
655 | =back |
656 | |
657 | =item * |
658 | |
659 | APPENDIX 3: IMPROVED HASHING SCRIPT |
660 | |
661 | =back |
662 | |
663 | |
664 | =head1 THANKS |
665 | |
666 | This tutorial would not have been possible without the input of many |
667 | different people in the Catalyst community. In particular, the |
668 | primary author would like to thank: |
669 | |
670 | =over 4 |
671 | |
672 | =item * |
673 | |
674 | Sebastian Riedel for founding the Catalyst project. |
675 | |
676 | =item * |
677 | |
678 | The members of the Catalyst Core Team for their tireless efforts to |
679 | advance the Catalyst project. Although all of the Core Team members |
680 | have played a key role in this tutorial, it would have never been |
681 | possible without the critical contributions of: Matt Trout, for his |
682 | unfathomable knowledge of all things Perl and Catalyst (and his |
683 | willingness to answer lots of my questions); Jesse Sheidlower, for his |
684 | incredible skill with the written word and dedication to improving the |
685 | Catalyst documentation; and Yuval Kogman, for his work on the Catalyst |
686 | "Auth & Authz" plugins (the original focus of the tutorial) and other |
687 | key Catalyst modules. |
688 | |
689 | =item * |
690 | |
691 | Other Catalyst documentation folks like Kieren Diment, Gavin Henry, |
692 | and Jess Robinson (including their work on the original Catalyst |
3533daff |
693 | tutorial). |
694 | |
695 | =item * |
696 | |
474c24ba |
697 | Kieren Diment for his oversite of Catalyst-related documentation. |
5e602627 |
698 | |
699 | =item * |
700 | |
701 | Everyone on #catalyst and #catalyst-dev. |
702 | |
703 | =item * |
704 | |
3533daff |
705 | Louis Moore (who thanks Marcello Romani and Tom Lanyon) for the |
706 | PostgreSQL content in the Appendix. |
707 | |
708 | =item * |
709 | |
5e602627 |
710 | People who have emailed me with corrections and suggestions on the |
1435672d |
711 | tutorial. As of the most recent release, this include: Florian |
712 | Ragwitz, Mauro Andreolini, Jim Howard, Giovanni Gigante, William |
713 | Moreno, Bryan Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning |
714 | Sprang, Jeremy Jones, David Kurtz, Ingo Wichmann, Shlomi Fish, Murray |
25b7b34a |
715 | Walker and Adam Witney. Thanks to Devin Austin for coming up with an |
716 | initial version of a non-TTSite wrapper page. Also, a huge thank you |
717 | to Kiffin Gish for all the hard work on the "database depluralization" |
718 | effort! I'm sure I am missing some names here... apologies for that |
719 | (please let me know if you name should be here). |
5e602627 |
720 | |
721 | =back |
722 | |
723 | =head1 AUTHOR |
724 | |
725 | Kennedy Clark, C<hkclark@gmail.com> |
726 | |
727 | Please report any errors, issues or suggestions to the author. The |
728 | most recent version of the Catalyst Tutorial can be found at |
59884771 |
729 | L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>. |
5e602627 |
730 | |
45c7830f |
731 | Copyright 2006-2008, Kennedy Clark, under Creative Commons License |
5e602627 |
732 | (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>). |