Commit | Line | Data |
d442cc9f |
1 | =head1 NAME |
2 | |
3ab6187c |
3 | Catalyst::Manual::Tutorial::01_Intro - Catalyst Tutorial - Chapter 1: Introduction |
d442cc9f |
4 | |
5 | |
6 | =head1 OVERVIEW |
7 | |
4b4d3884 |
8 | This is B<Chapter 1 of 10> for the Catalyst tutorial. |
d442cc9f |
9 | |
10 | L<Tutorial Overview|Catalyst::Manual::Tutorial> |
11 | |
12 | =over 4 |
13 | |
14 | =item 1 |
15 | |
3ab6187c |
16 | B<01_Introduction> |
d442cc9f |
17 | |
18 | =item 2 |
19 | |
3ab6187c |
20 | L<Catalyst Basics|Catalyst::Manual::Tutorial::02_CatalystBasics> |
d442cc9f |
21 | |
22 | =item 3 |
23 | |
3ab6187c |
24 | L<More Catalyst Basics|Catalyst::Manual::Tutorial::03_MoreCatalystBasics> |
d442cc9f |
25 | |
26 | =item 4 |
27 | |
3ab6187c |
28 | L<Basic CRUD|Catalyst::Manual::Tutorial::04_BasicCRUD> |
d442cc9f |
29 | |
30 | =item 5 |
31 | |
3ab6187c |
32 | L<Authentication|Catalyst::Manual::Tutorial::05_Authentication> |
d442cc9f |
33 | |
34 | =item 6 |
35 | |
3ab6187c |
36 | L<Authorization|Catalyst::Manual::Tutorial::06_Authorization> |
d442cc9f |
37 | |
38 | =item 7 |
39 | |
3ab6187c |
40 | L<Debugging|Catalyst::Manual::Tutorial::07_Debugging> |
d442cc9f |
41 | |
42 | =item 8 |
43 | |
3ab6187c |
44 | L<Testing|Catalyst::Manual::Tutorial::08_Testing> |
d442cc9f |
45 | |
46 | =item 9 |
47 | |
3ab6187c |
48 | L<Advanced CRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD> |
1def4a20 |
49 | |
50 | =item 10 |
51 | |
3ab6187c |
52 | L<Appendices|Catalyst::Manual::Tutorial::10_Appendices> |
d442cc9f |
53 | |
54 | =back |
55 | |
1def4a20 |
56 | |
d442cc9f |
57 | =head1 DESCRIPTION |
58 | |
ffeb7448 |
59 | This tutorial provides a multi-part introduction to the Catalyst web |
d442cc9f |
60 | framework. It seeks to provide a rapid overview of many of its most |
61 | commonly used features. The focus is on the real-world best practices |
62 | required in the construction of nearly all Catalyst applications. |
63 | |
64 | Although the primary target of the tutorial is users new to the Catalyst |
65 | framework, experienced users may wish to review specific sections (for |
1def4a20 |
66 | example, how to use DBIC for their model classes, how to add |
8168726b |
67 | authentication and authorization to an existing application, and/or |
68 | form management). |
d442cc9f |
69 | |
70 | You can obtain the code for all the tutorial examples from the |
71 | catalyst subversion repository by issuing the command: |
72 | |
028b4e1a |
73 | svn co http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/ CatalystTutorial |
d442cc9f |
74 | |
75b13da6 |
75 | This will download the most recent code for each chapter of the |
76 | tutorial into the CatalystTutorial directory on your machine. |
d442cc9f |
77 | |
3d9ae335 |
78 | B<These reference implementations are provided so that when you follow |
79 | the tutorial, you can use the code from the subversion repository to |
80 | ensure that your system is set up correctly, and that you have not |
81 | inadvertently made any typographic errors, or accidentally skipped |
82 | part of the tutorial.> |
83 | |
8168726b |
84 | B<NOTE: You can use any Perl-supported OS and environment to run |
85 | Catalyst.> It should make little or no difference to Catalyst's |
a6b4cff5 |
86 | operation, B<but this tutorial has been written using the Debian 6 Live |
8168726b |
87 | CD> because that represents a quick and easy way for most people to try |
88 | out Catalyst with virtually zero setup time and hassles. Also, the |
89 | tutorial has been tested to work correctly with the versions of Catalyst |
90 | and all the supporting modules in Debian 6 (see "VERSIONS AND |
91 | CONVENTIONS USED IN THIS TUTORIAL" below for the specific versions for |
92 | some of the key modules), so B<if you think you might be running into an |
93 | issue related to versions> (for example, a module changed its behavior |
94 | in a newer version or a bug was introduced), B<it might be worth giving |
95 | Debian 6 a try>. |
96 | |
97 | If you plan to follow along with Debian 6, you can jump down to the |
98 | "Debian" section under L</"CATALYST INSTALLATION"> below and it will |
99 | walk you though the setup of a fully functional Catalyst environment. If |
100 | you would prefer to install directly from CPAN, you can download the |
101 | example program and all the necessary dependencies to your local machine |
102 | by installing the C<Task::Catalyst::Tutorial> distribution: |
d442cc9f |
103 | |
104 | cpan Task::Catalyst::Tutorial |
105 | |
106 | This will also test to make sure the dependencies are working. If you |
107 | have trouble installing these, please ask for help on the #catalyst |
108 | IRC channel, or the Catalyst mailing list. |
109 | |
3533daff |
110 | Subjects covered by the tutorial include: |
d442cc9f |
111 | |
112 | =over 4 |
113 | |
114 | =item * |
115 | |
116 | A simple application that lists and adds books. |
117 | |
118 | =item * |
119 | |
2217b252 |
120 | The use of L<DBIx::Class> (DBIC) for the model (including |
8168726b |
121 | some of the more advanced techniques you will probably want to use in |
acbd7bdd |
122 | your applications). |
d442cc9f |
123 | |
124 | =item * |
125 | |
126 | How to write CRUD (Create, Read, Update, and Delete) operations in |
127 | Catalyst. |
128 | |
129 | =item * |
130 | |
131 | Authentication ("auth"). |
132 | |
133 | =item * |
134 | |
135 | Role-based authorization ("authz"). |
136 | |
137 | =item * |
138 | |
8168726b |
139 | Attempts to provide an example showing current (5.9) Catalyst |
140 | practices. |
d442cc9f |
141 | |
142 | =item * |
143 | |
1390ef0e |
144 | The use of Template Toolkit (TT). |
d442cc9f |
145 | |
146 | =item * |
147 | |
148 | Useful techniques for troubleshooting and debugging Catalyst |
149 | applications. |
150 | |
151 | =item * |
152 | |
153 | The use of SQLite as a database (with code also provided for MySQL and |
8168726b |
154 | PostgreSQL). (Note: Because we make use of the DBIx::Class Object |
444d6b27 |
155 | Relational Mapping [ORM] layer, out our application will be database |
8168726b |
156 | agnostic and can easily be used by any of the databases supported by |
157 | DBIx::Class.) |
d442cc9f |
158 | |
159 | =item * |
160 | |
2217b252 |
161 | The use of L<HTML::FormFu> or L<HTML::FormHandler> |
0abc72ed |
162 | for automated form processing and validation. |
d442cc9f |
163 | |
164 | =back |
165 | |
166 | This tutorial makes the learning process its main priority. For |
167 | example, the level of comments in the code found here would likely be |
1def4a20 |
168 | considered excessive in a "normal project." Because of their contextual |
d442cc9f |
169 | value, this tutorial will generally favor inline comments over a |
170 | separate discussion in the text. It also deliberately tries to |
171 | demonstrate multiple approaches to various features (in general, you |
172 | should try to be as consistent as possible with your own production |
173 | code). |
174 | |
175 | Furthermore, this tutorial tries to minimize the number of controllers, |
176 | models, TT templates, and database tables. Although this does result in |
177 | things being a bit contrived at times, the concepts should be applicable |
178 | to more complex environments. More complete and complicated example |
179 | applications can be found in the C<examples> area of the Catalyst |
180 | Subversion repository at |
181 | L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/>. |
8168726b |
182 | ***Todo: update link above? |
d442cc9f |
183 | |
1390ef0e |
184 | |
2e73e2be |
185 | =head1 QUICK START |
186 | |
8168726b |
187 | For those who want to get going quickly, here is a short "cookbook-style |
188 | recipe" to quickly get you up and running. Although there are many |
189 | different ways to get a Catalyst environment going, this tutorial has |
a6b4cff5 |
190 | been written with and tested against the Debian 6 Live CD, using the |
191 | steps in this Quick Start. |
2e73e2be |
192 | |
8168726b |
193 | If you want, you can follow the directions in this section and then jump |
194 | right to L<Chapter 2|Catalyst::Manual::Tutorial::02_CatalystBasics> of |
195 | the tutorial. However, it would be a good idea to come back and read the |
196 | sections below the Quick Start when you have time. Or, continue reading |
197 | those other sections for suggestions if you do not wish to use the |
198 | Debian 6 Live CD. |
2e73e2be |
199 | |
2e73e2be |
200 | =over 4 |
201 | |
202 | =item 1 |
203 | |
8168726b |
204 | Download the C<debian-live-6.0.1-i386-rescue.iso> image from |
205 | L<http://cdimage.debian.org/cdimage/release/current-live/i386/iso-hybrid/>. |
2e73e2be |
206 | |
207 | =item 2 |
208 | |
209 | Boot this disk, either in a physical machine, or possibly some sort |
8168726b |
210 | of virtual machine (using a VM can be a very handy way to practice). |
2e73e2be |
211 | |
212 | =item 3 |
213 | |
214 | Select "C<Live>" from the initial boot menu. |
215 | |
216 | =item 4 |
217 | |
218 | At the "C<user@debian:~$>" prompt, type: |
219 | |
220 | sudo aptitude -y install subversion |
221 | |
222 | =item 5 |
223 | |
224 | If you want to be able to remotely SSH to this system, set a |
a6b4cff5 |
225 | password for root (you might want to do "dpkg -l | grep openssh-server" |
226 | to be sure the ISO image you downloaded has the SSH daemon installed... |
227 | if it's missing, do a "sudo aptitude -y install openssh-server"): |
2e73e2be |
228 | |
229 | sudo passwd |
230 | ... |
231 | |
232 | =item 6 |
233 | |
234 | Add the "unstable" Debian package repository: |
235 | |
236 | sudo vi /etc/apt/sources.list |
237 | |
238 | Add the following line to the bottom of this file: |
239 | |
240 | deb http://ftp.us.debian.org/debian/ unstable main |
241 | |
242 | =item 7 |
243 | |
244 | Install Catalyst and related libraries: |
245 | |
246 | sudo aptitude update |
a5628822 |
247 | sudo aptitude -y install libcatalyst-perl libdatetime-format-sqlite-perl \ |
248 | libdbix-class-encodedcolumn-perl sqlite3 libcatalyst-modules-perl \ |
249 | libperl6-junction-perl libcatalyst-modules-extra-perl \ |
250 | libdbix-class-timestamp-perl |
2e73e2be |
251 | sudo aptitude clean |
252 | |
253 | =item 8 |
254 | |
255 | Test example code: |
256 | |
257 | mkdir test |
258 | cd test |
259 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter8 |
260 | cd MyApp_Chapter8/MyApp |
261 | CATALYST_DEBUG=0 prove -wl t |
262 | cd |
263 | |
264 | =back |
265 | |
266 | |
d442cc9f |
267 | =head1 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL |
268 | |
269 | This tutorial was built using the following resources. Please note that |
a6b4cff5 |
270 | you may need to make adjustments for different environments and versions |
271 | (note that trailing zeros in version numbers are not significant and may |
272 | get dropped with some techniques for viewing them; for example, Catalyst |
273 | v5.80020 might show up as 5.8002): |
d442cc9f |
274 | |
275 | =over 4 |
276 | |
277 | =item * |
278 | |
95968b61 |
279 | Debian 6 (Squeeze) |
d442cc9f |
280 | |
281 | =item * |
282 | |
95968b61 |
283 | Catalyst v5.80025 |
dd88c3b6 |
284 | |
22a67212 |
285 | =item * |
dd88c3b6 |
286 | |
95968b61 |
287 | Catalyst::Devel v1.28 |
d442cc9f |
288 | |
289 | =item * |
290 | |
95968b61 |
291 | DBIx::Class v0.08123 |
d442cc9f |
292 | |
fce83e5f |
293 | =item * |
294 | |
95968b61 |
295 | Catalyst::Model::DBIC::Schema v0.41 |
2e73e2be |
296 | |
297 | =item * |
298 | |
95968b61 |
299 | Template Toolkit v2.22 |
fce83e5f |
300 | |
2e73e2be |
301 | |
d442cc9f |
302 | =item * |
303 | |
95968b61 |
304 | HTML::FormFu -- v0.07002 |
2e73e2be |
305 | |
d442cc9f |
306 | =item * |
307 | |
865d3efb |
308 | B<NOTE:> You can check the versions you have installed with the |
95968b61 |
309 | following command (note the slash before the space): |
310 | |
311 | perl -M<_mod_name_>\ 999 |
312 | |
313 | or: |
865d3efb |
314 | |
f63a9a2b |
315 | perl -M<_mod_name_> -e 'print "$<_mod_name_>::VERSION\n"' |
865d3efb |
316 | |
317 | For example: |
865d3efb |
318 | |
95968b61 |
319 | perl -MCatalyst::Devel\ 999 |
444d6b27 |
320 | |
321 | or: |
322 | |
323 | perl -MCatalyst::Devel -e 'print "$Catalyst::Devel::VERSION\n";' |
d442cc9f |
324 | |
325 | =item * |
326 | |
8168726b |
327 | This tutorial will assume that the web browser is located on the same |
328 | system where the Catalyst development server is running, and therefore |
329 | use a URL of C<http://localhost:3000> (the Catalyst development server |
a6b4cff5 |
330 | defaults to port 3000, but can be changed with the "-p" option to the |
331 | development server). If you are running Perl on a different box than |
8168726b |
332 | where your web browser is located (or using a different port number via |
333 | the C<-p> I<port_number> option to the development server), then you |
334 | will need to update the URL you use accordingly. |
335 | |
336 | Please Note: Depending on the web browser you are using, you might need |
337 | to hit C<Shift+Reload> or C<Ctrl+Reload> to pull a fresh page when |
338 | testing your application at various points (see |
339 | L<http://en.wikipedia.org/wiki/Bypass_your_cache> for a comprehensive |
340 | list of options for each browser). Also, the C<-k> keepalive option to |
341 | the development server can be necessary with some browsers (especially |
342 | Internet Explorer). ***Todo: is this still true? |
d442cc9f |
343 | |
344 | =back |
345 | |
1390ef0e |
346 | |
d442cc9f |
347 | =head1 CATALYST INSTALLATION |
348 | |
8168726b |
349 | Although Catalyst installation has been a challenge in the past, the |
350 | good news is that there are a growing number of options to eliminate (or |
351 | at least dramatically simplify) this concern. Although a compelling |
352 | strength of Catalyst is that it makes use of many of the modules in the |
353 | vast repository that is CPAN, this can complicate the installation |
354 | process if you approach it in the wrong way. Consider the following |
355 | suggestions on the most common ways to get started with a Catalyst |
356 | development environment: |
1def4a20 |
357 | |
358 | =over 4 |
359 | |
360 | =item * |
361 | |
acbd7bdd |
362 | Debian |
363 | |
8168726b |
364 | The Debian 6 Live CD represents a great way for newcomers to experiment |
365 | with Catalyst. As a "live CD," you can simple boot from the CD, run a |
366 | few commands, and in a matter of minutes you should have a fully |
367 | function environment in which do this tutorial. B<The tutorial was fully |
368 | tested to work under Debian 6. Although it SHOULD work under any |
369 | Catalyst installation method you might choose, it can be hard to |
370 | guarantee this.> |
acbd7bdd |
371 | |
372 | =over 4 |
373 | |
374 | =item * |
375 | |
8168726b |
376 | Download one of the ISO files from |
377 | L<http://cdimage.debian.org/cdimage/release/current-live/i386/iso-hybrid/> |
378 | (the current version at the time this was written was 6.0.1). You can |
379 | pick any one of the live CD variations will work, but you may wish to |
380 | consider the following points: |
acbd7bdd |
381 | |
382 | =over 4 |
383 | |
384 | =item * |
385 | |
8168726b |
386 | "C<debian-live-6.0.1-i386-rescue.iso>" is probably the best all-around |
387 | option for most people because it includes many extra tools such as the |
388 | GCC compiler, therefore saving RAM (every package you need to install |
a6b4cff5 |
389 | when running from a Live CD consumes memory because RAM disk is being |
390 | used in lieu of real disk space). When initially booting under this |
391 | image, you may see some cryptic warning messages having to do with |
392 | various diagnostic tools it tries to load or enable, but you should be |
393 | able to safely ignore these. |
acbd7bdd |
394 | |
395 | =item * |
396 | |
8168726b |
397 | "C<debian-live-6.0.1-i386-standard.iso>" is a great option because of |
398 | its compact size, but you will probably need approximately 1 GB of RAM |
399 | in the computer where you will run the tutorial. Because the "standard" |
400 | live CD comes with with a minimal set of tools, we will have to install |
401 | extra packages (such as the GCC compiler), all of which will require RAM |
402 | when running from a live CD. |
acbd7bdd |
403 | |
404 | =item * |
405 | |
8168726b |
406 | The other ISO images include different flavors of X-Windows desktop |
407 | managers. You can select one of these if you don't mind the larger |
408 | download size and prefer a graphical environment. Be aware that these |
409 | disks do not come with the extra tools found on the "rescue" image, so |
410 | you will need adequate RAM to be able to install them just as you would |
411 | under the "standard" image. B<Use one of the "graphical" ISO images if |
412 | you want a graphical web browser on the same machine as where you will |
413 | run the tutorial.> (If you are using one of the non- graphical images |
414 | discussed above, you can still use a graphical web browser from another |
415 | machine and point it to your Catalyst development machine.) |
acbd7bdd |
416 | |
417 | =back |
418 | |
419 | =item * |
420 | |
421 | Boot off the CD. |
422 | |
423 | =item * |
424 | |
425 | Select "C<Live>" from the initial boot menu. |
426 | |
427 | =item * |
428 | |
6163536a |
429 | Once the system has booted to a "C<user@debian:~$>" prompt, first |
430 | install the Subversion client in case you want to check out the |
431 | completed chapter example code: |
432 | |
0ed3df53 |
433 | sudo aptitude -y install subversion |
6163536a |
434 | |
2e73e2be |
435 | If you want to be able to remotely SSH to this system, set a |
436 | password for root: |
437 | |
438 | sudo passwd |
439 | ... |
440 | |
8168726b |
441 | Then enter the following command to add the more current "unstable" |
442 | package repository so we get the latest versions of Catalyst and related |
443 | packages: |
acbd7bdd |
444 | |
445 | sudo vi /etc/apt/sources.list |
446 | |
447 | Add the following line to the bottom of this file: |
448 | |
449 | deb http://ftp.us.debian.org/debian/ unstable main |
450 | |
8168726b |
451 | If you are not familiar with VI, you can move to the bottom of this file |
452 | and press the "o" key to insert a new line and type the line above. |
453 | Then press the "Esc" key followed by a colon (":"), the letters "wq" and |
454 | then the "Enter" key. The rest of the tutorial will assume that you |
455 | know how to use some editor that is available from the Linux |
456 | command-line environment. |
acbd7bdd |
457 | |
458 | =item * |
459 | |
460 | Install Catalyst: |
461 | |
462 | sudo aptitude update |
a5628822 |
463 | sudo aptitude -y install libcatalyst-perl libdatetime-format-sqlite-perl \ |
464 | libdbix-class-encodedcolumn-perl sqlite3 libcatalyst-modules-perl \ |
465 | libperl6-junction-perl libcatalyst-modules-extra-perl \ |
466 | libdbix-class-timestamp-perl |
467 | |
468 | Let it install (normally about a 30 to 90-second operation) and you are |
469 | done. (Note the '\' above. Depending on your environment, you might be |
470 | able to cut and paste the text as shown or need to remove the '\' |
fce83e5f |
471 | characters to that the command is all on a single line.) |
acbd7bdd |
472 | |
473 | If you are using an image other than the "rescue" ISO, you will also need |
474 | to run the following command to install additional packages: |
475 | |
476 | sudo aptitude -y install gcc make libc6-dev |
477 | |
8168726b |
478 | If you are running from the Live CD, you probably also want to free up |
acbd7bdd |
479 | some RAM disk space with the following: |
480 | |
481 | sudo aptitude clean |
482 | |
8168726b |
483 | NOTE: While the instructions above mention the Live CD because that |
484 | makes it easy for people new to Linux, you can obviously pick a |
485 | different Debian ISO image and install it to your hard drive. Although |
486 | there are many different ways to download and install Debian, the |
487 | "netinst" ISO image (such as "C<debian-500-i386-netinst.iso>" represents |
488 | a great option because it keeps your initial download small (but still |
489 | lets you install anything you want "over the network"). |
acbd7bdd |
490 | |
491 | Here are some tips if you are running from a live CD and are running |
492 | out of disk space (which really means you are running out of RAM): |
493 | |
494 | =over 4 |
495 | |
496 | =item * |
497 | |
8168726b |
498 | Always run "C<aptitude clean>" after you install new packages to delete |
499 | the original .deb files (the files installed B<by> the .deb package |
500 | B<will> remain available, just the .deb package itself is deleted). |
acbd7bdd |
501 | |
502 | =item * |
503 | |
8168726b |
504 | If you are installing modules from CPAN, you can free up some space with |
505 | "C<rm -rf /root/.cpan/*>" (change "/root/" in the previous command to |
506 | match your home directory or the location where CPAN has been configured |
507 | to perform build operations). |
acbd7bdd |
508 | |
509 | =item * |
510 | |
8168726b |
511 | If necessary, you can remove the cached package information with the |
512 | command "C<rm -f /var/lib/apt/lists/*>". You can later pull this |
acbd7bdd |
513 | information again via the command "C<aptitude update>". |
514 | |
515 | =item * |
516 | |
8168726b |
517 | You can save a small amount of space by commenting out the lines in |
518 | C</etc/apt/sources.list> that reference "deb-src" and |
519 | "security.debian.org". If you have already done an "C<aptitude update>" |
520 | with these repositories enabled, you can use the tip in the previous |
521 | bullet to free the space up (and then do another "C<aptitude update>"). |
acbd7bdd |
522 | |
523 | =item * |
524 | |
8168726b |
525 | Although you can free up space by removing packages you installed since |
a6b4cff5 |
526 | you last booted (check out "C<aptitude remove _pkg_name_>"), don't bother |
8168726b |
527 | trying to remove packages already available at the time of boot. Instead |
a6b4cff5 |
528 | of freeing up space, it will actual consume I<more> space. (The live CD |
8168726b |
529 | uses these "burn in" packages right from the CD disk vs. first loading |
530 | them on the virtual RAM disk. However, if you remove them, the system |
531 | has to update various files, something that I<does> consume some space |
532 | on the virtual RAM disk.) |
acbd7bdd |
533 | |
534 | =back |
535 | |
536 | =back |
537 | |
538 | =item * |
539 | |
1def4a20 |
540 | Ubuntu |
541 | |
a6b4cff5 |
542 | Ubuntu is a popular offshoot of Debian. It provides cutting edge |
543 | versions of many common tools, application and libraries in an |
8168726b |
544 | easy-to-run live CD configuration (and because a single download option |
545 | can be used for both live CD and install-to-disk usage, it keeps your |
546 | download options nice and simple). As with Debian 6, you should be able |
547 | to generate a fully function Catalyst environment in a matter of |
548 | minutes. Here are quick instructions on how to use Ubuntu to prepare |
549 | for the tutorial: |
d442cc9f |
550 | |
551 | =over 4 |
552 | |
553 | =item * |
554 | |
8168726b |
555 | Download the Ubuntu Desktop edition and boot from the CD and/or image |
556 | file, select your language, and then "Try Ubuntu without any changes to |
557 | your computer." |
1def4a20 |
558 | |
559 | =item * |
560 | |
8168726b |
561 | Open a terminal session (click "Applications" in the upper-left corner, |
562 | then "Accessories," then "Terminal"). |
1def4a20 |
563 | |
564 | =item * |
565 | |
566 | Add the 'universe' repositories: |
567 | |
3533daff |
568 | sudo gedit /etc/apt/sources.list |
1def4a20 |
569 | |
570 | And remove the comments from the lines under the comments about the |
571 | 'universe' repositories. |
572 | |
573 | =item * |
574 | |
575 | Install Catalyst: |
576 | |
acbd7bdd |
577 | sudo aptitude update |
578 | sudo aptitude install libdbd-sqlite3-perl libcatalyst-perl libcatalyst-modules-perl libconfig-general-perl |
1def4a20 |
579 | |
8168726b |
580 | Accept all of the dependencies. Done. |
2b75577c |
581 | |
8168726b |
582 | If you are running from the Live CD, you probably also want to free up |
2b75577c |
583 | some disk space with the following: |
584 | |
acbd7bdd |
585 | sudo aptitude clean |
2b75577c |
586 | |
8168726b |
587 | NOTE: While the instructions above mention the live CD because that |
588 | makes it easy for people new to Linux, you can obviously also use one of |
589 | the options to install Ubuntu on your drive. |
3533daff |
590 | |
1def4a20 |
591 | =back |
592 | |
593 | =item * |
594 | |
d442cc9f |
595 | Matt Trout's C<cat-install> |
596 | |
8168726b |
597 | Available at L<http://www.shadowcat.co.uk/static/cat-install>, |
598 | C<cat-install> can be a fairly painless way to get Catalyst up and |
a6b4cff5 |
599 | running. Just download the script from the link above and type |
600 | C<perl cat-install>. Depending on the speed of your Internet connection |
601 | and your computer, it will probably take 30 to 60 minutes to install |
602 | because it downloads, makes, compiles, and tests every module. But this |
603 | is an excellent way to automate the installation of all the latest |
604 | modules used by Catalyst from CPAN. |
ffeb7448 |
605 | |
d442cc9f |
606 | |
607 | =item * |
608 | |
ffeb7448 |
609 | Other Possibilities |
610 | |
611 | =over 4 |
612 | |
613 | =item * |
614 | |
615 | OpenBSD Packages |
616 | |
8168726b |
617 | The 2008 Advent Day 4 entry has more information on using OpenBSD |
618 | packages to quickly build a system: |
ffeb7448 |
619 | L<http://www.catalystframework.org/calendar/2008/4>. |
620 | |
621 | =item * |
d442cc9f |
622 | |
ffeb7448 |
623 | NetBSD Package Collection on Solaris |
624 | |
8168726b |
625 | The 2008 Advent Day 15 entry has more information on using C<pkgsrc> and |
626 | NetBSD packages on Solaris: |
1435672d |
627 | L<http://www.catalystframework.org/calendar/2008/15>. |
d442cc9f |
628 | |
629 | =item * |
630 | |
ffeb7448 |
631 | CatInABox |
632 | |
8168726b |
633 | You can get more information at |
634 | L<http://www.catalystframework.org/calendar/2008/7> or |
2217b252 |
635 | L<Perl::Dist::CatInABox>. |
ffeb7448 |
636 | |
0c51850e |
637 | =item * |
638 | |
639 | Frank Speiser's Amazon EC2 Catalyst SDK |
640 | |
641 | There are currently two flavors of publicly available Amazon Machine |
642 | Images (AMI) that include all the elements you'd need to begin |
643 | developing in a fully functional Catalyst environment within minutes. |
2217b252 |
644 | See L<Catalyst::Manual::Installation> |
0c51850e |
645 | for more details. |
646 | |
d442cc9f |
647 | =back |
648 | |
ffeb7448 |
649 | =back |
650 | |
d442cc9f |
651 | For additional information and recommendations on Catalyst installation, |
8168726b |
652 | please refer to |
2217b252 |
653 | L<Catalyst::Manual::Installation>. |
d442cc9f |
654 | |
1390ef0e |
655 | |
d442cc9f |
656 | =head1 DATABASES |
657 | |
658 | This tutorial will primarily focus on SQLite because of its simplicity |
659 | of installation and use; however, modifications in the script required |
a6b4cff5 |
660 | to support MySQL and PostgreSQL will be presented in the Appendix. |
d442cc9f |
661 | |
a6b4cff5 |
662 | B<Note:> One of the advantages of using tools like Catalyst and DBIC is |
663 | that applications become much more database independent. As such, you |
664 | will notice that only the C<.sql> files used to initialize the database |
665 | change between database systems: most of the code generally remains the |
d442cc9f |
666 | same. |
667 | |
1390ef0e |
668 | |
d442cc9f |
669 | =head1 WHERE TO GET WORKING CODE |
670 | |
8168726b |
671 | Each chapter of the tutorial has complete code available as a tarball in |
672 | the main Catalyst Subversion repository (see the note at the beginning |
028b4e1a |
673 | of each part for the appropriate svn command to use). |
d442cc9f |
674 | |
8168726b |
675 | B<NOTE:> You can run the test cases for the final code through Chapter 8 |
028b4e1a |
676 | with the following commands: |
d442cc9f |
677 | |
0ed3df53 |
678 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter8 |
679 | cd MyApp_Chapter8/MyApp |
96a87356 |
680 | CATALYST_DEBUG=0 prove -wl t |
d442cc9f |
681 | |
2217b252 |
682 | If you wish to include the L<HTML::FormFu> section in your tests, |
6163536a |
683 | substitute C<MyApp_Chapter9_FormFu> for C<MyApp_Chapter8> in the URL |
684 | above (don't forget to "cd" out of the Ch8 directory if you ran the code above). |
acbd7bdd |
685 | |
0ed3df53 |
686 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter9_FormFu |
687 | cd MyApp_Chapter9_FormFu/MyApp |
96a87356 |
688 | CATALYST_DEBUG=0 prove -wl t |
acbd7bdd |
689 | |
690 | You can also fire up the application under the development server that is conveniently |
691 | built in to Catalyst. Just issue this command from the C<MyApp> directory where you |
692 | ran the test suite above: |
693 | |
694 | script/myapp_server.pl |
695 | |
8168726b |
696 | And the application will start. You can try out the application by |
697 | pulling up C<http://localhost:3000> in your web browser (as mentioned |
698 | earlier, change C<localhost> to a different IP address or DNS name if |
699 | you are running your web browser and your Catalyst development on |
700 | different boxes). We will obviously see more about how to use the |
701 | application as we go through the remaining chapters of the tutorial, but |
702 | for now you can log in using the username "test01" and a password of |
acbd7bdd |
703 | "mypass". |
704 | |
d442cc9f |
705 | |
706 | =head1 AUTHOR |
707 | |
708 | Kennedy Clark, C<hkclark@gmail.com> |
709 | |
8168726b |
710 | Please report any errors, issues or suggestions to the author. The |
711 | most recent version of the Catalyst Tutorial can be found at |
59884771 |
712 | L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>. |
d442cc9f |
713 | |
ec3ef4ad |
714 | Copyright 2006-2010, Kennedy Clark, under the |
715 | Creative Commons Attribution Share-Alike License Version 3.0 |
865d3efb |
716 | (L<http://creativecommons.org/licenses/by-sa/3.0/us/>). |