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 |
86 | operation, B<but this tutorial has been written using the Debian 6 live |
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 | |
8168726b |
120 | The use of L<DBIx::Class|DBIx::Class> (DBIC) for the model (including |
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 | |
0abc72ed |
161 | The use of L<HTML::FormFu|HTML::FormFu> or L<HTML::FormHandler|HTML::FormHandler> |
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 |
190 | been written with and tested against Debian 6 Live CD, using the steps |
191 | 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 | |
200 | |
201 | =over 4 |
202 | |
203 | =item 1 |
204 | |
8168726b |
205 | Download the C<debian-live-6.0.1-i386-rescue.iso> image from |
206 | L<http://cdimage.debian.org/cdimage/release/current-live/i386/iso-hybrid/>. |
2e73e2be |
207 | |
208 | =item 2 |
209 | |
210 | Boot this disk, either in a physical machine, or possibly some sort |
8168726b |
211 | of virtual machine (using a VM can be a very handy way to practice). |
2e73e2be |
212 | |
213 | =item 3 |
214 | |
215 | Select "C<Live>" from the initial boot menu. |
216 | |
217 | =item 4 |
218 | |
219 | At the "C<user@debian:~$>" prompt, type: |
220 | |
221 | sudo aptitude -y install subversion |
222 | |
223 | =item 5 |
224 | |
225 | If you want to be able to remotely SSH to this system, set a |
226 | password for root: |
227 | |
228 | sudo passwd |
229 | ... |
230 | |
231 | =item 6 |
232 | |
233 | Add the "unstable" Debian package repository: |
234 | |
235 | sudo vi /etc/apt/sources.list |
236 | |
237 | Add the following line to the bottom of this file: |
238 | |
239 | deb http://ftp.us.debian.org/debian/ unstable main |
240 | |
241 | =item 7 |
242 | |
243 | Install Catalyst and related libraries: |
244 | |
245 | sudo aptitude update |
246 | sudo aptitude -y install sqlite3 libdbd-sqlite3-perl libcatalyst-perl \ |
247 | libcatalyst-modules-perl libdbix-class-timestamp-perl \ |
248 | libdatetime-format-sqlite-perl libconfig-general-perl \ |
249 | libhtml-formfu-model-dbic-perl libterm-readline-perl-perl \ |
195424f2 |
250 | libdbix-class-encodedcolumn-perl libperl6-junction-perl \ |
251 | libtest-pod-perl |
2e73e2be |
252 | sudo aptitude clean |
253 | |
254 | =item 8 |
255 | |
256 | Test example code: |
257 | |
258 | mkdir test |
259 | cd test |
260 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter8 |
261 | cd MyApp_Chapter8/MyApp |
262 | CATALYST_DEBUG=0 prove -wl t |
263 | cd |
264 | |
265 | =back |
266 | |
267 | |
d442cc9f |
268 | =head1 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL |
269 | |
270 | This tutorial was built using the following resources. Please note that |
271 | you may need to make adjustments for different environments and |
6163536a |
272 | versions (note that trailing zeros in version numbers are not |
273 | significant and may get dropped with techniques for viewing them; |
274 | for example, Catalyst v5.80020 might show up as 5.8002): |
d442cc9f |
275 | |
276 | =over 4 |
277 | |
278 | =item * |
279 | |
acbd7bdd |
280 | Debian 5 (Lenny) |
d442cc9f |
281 | |
282 | =item * |
283 | |
6163536a |
284 | Catalyst v5.80020 (note: may show up as '5.8002' without the trailing zero) |
dd88c3b6 |
285 | |
22a67212 |
286 | =item * |
dd88c3b6 |
287 | |
6163536a |
288 | Catalyst::Devel v1.26 |
d442cc9f |
289 | |
290 | =item * |
291 | |
6163536a |
292 | DBIx::Class v0.08115 |
d442cc9f |
293 | |
fce83e5f |
294 | =item * |
295 | |
2e73e2be |
296 | Catalyst::Model::DBIC::Schema v0.40 |
297 | |
298 | =item * |
299 | |
fce83e5f |
300 | Template Toolkit v2.20 |
301 | |
2e73e2be |
302 | |
d442cc9f |
303 | =item * |
304 | |
305 | Catalyst Plugins |
306 | |
307 | The plugins used in this tutorial all have sufficiently stable APIs that |
308 | you shouldn't need to worry about versions. However, there could be |
309 | cases where the tutorial is affected by what version of plugins you |
310 | use. This tutorial has been tested against the following set of plugins: |
311 | |
312 | =over 4 |
313 | |
314 | =item * |
315 | |
6163536a |
316 | Catalyst::Plugin::Authentication -- v0.10016 |
d442cc9f |
317 | |
318 | =item * |
319 | |
6163536a |
320 | Catalyst::Plugin::Authorization::Roles -- v0.08 |
d442cc9f |
321 | |
322 | =item * |
323 | |
f34d7f62 |
324 | Catalyst::Plugin::ConfigLoader -- v0.27 |
d442cc9f |
325 | |
326 | =item * |
327 | |
f34d7f62 |
328 | Catalyst::Plugin::Session -- v0.29 |
d442cc9f |
329 | |
330 | =item * |
331 | |
f34d7f62 |
332 | Catalyst::Plugin::Session::State::Cookie -- v0.17 |
d442cc9f |
333 | |
334 | =item * |
335 | |
95455c74 |
336 | Catalyst::Plugin::Session::Store::File -- v0.18 |
d442cc9f |
337 | |
338 | =item * |
339 | |
f34d7f62 |
340 | Catalyst::Plugin::StackTrace -- v0.11 |
d442cc9f |
341 | |
342 | =item * |
343 | |
2e73e2be |
344 | Catalyst::Plugin::Static::Simple -- v0.29 |
d442cc9f |
345 | |
346 | =back |
347 | |
2e73e2be |
348 | =item * |
349 | |
350 | HTML::FormFu -- v0.06001 |
351 | |
d442cc9f |
352 | =item * |
353 | |
865d3efb |
354 | B<NOTE:> You can check the versions you have installed with the |
355 | following command: |
356 | |
f63a9a2b |
357 | perl -M<_mod_name_> -e 'print "$<_mod_name_>::VERSION\n"' |
865d3efb |
358 | |
359 | For example: |
865d3efb |
360 | |
444d6b27 |
361 | perl -MCatalyst -e 'print "$Catalyst::VERSION\n";' |
362 | |
363 | or: |
364 | |
365 | perl -MCatalyst::Devel -e 'print "$Catalyst::Devel::VERSION\n";' |
d442cc9f |
366 | |
367 | =item * |
368 | |
8168726b |
369 | This tutorial will assume that the web browser is located on the same |
370 | system where the Catalyst development server is running, and therefore |
371 | use a URL of C<http://localhost:3000> (the Catalyst development server |
372 | defaults to port 3000). If you are running Perl on a different box than |
373 | where your web browser is located (or using a different port number via |
374 | the C<-p> I<port_number> option to the development server), then you |
375 | will need to update the URL you use accordingly. |
376 | |
377 | Please Note: Depending on the web browser you are using, you might need |
378 | to hit C<Shift+Reload> or C<Ctrl+Reload> to pull a fresh page when |
379 | testing your application at various points (see |
380 | L<http://en.wikipedia.org/wiki/Bypass_your_cache> for a comprehensive |
381 | list of options for each browser). Also, the C<-k> keepalive option to |
382 | the development server can be necessary with some browsers (especially |
383 | Internet Explorer). ***Todo: is this still true? |
d442cc9f |
384 | |
385 | =back |
386 | |
1390ef0e |
387 | |
d442cc9f |
388 | =head1 CATALYST INSTALLATION |
389 | |
8168726b |
390 | Although Catalyst installation has been a challenge in the past, the |
391 | good news is that there are a growing number of options to eliminate (or |
392 | at least dramatically simplify) this concern. Although a compelling |
393 | strength of Catalyst is that it makes use of many of the modules in the |
394 | vast repository that is CPAN, this can complicate the installation |
395 | process if you approach it in the wrong way. Consider the following |
396 | suggestions on the most common ways to get started with a Catalyst |
397 | development environment: |
1def4a20 |
398 | |
399 | =over 4 |
400 | |
401 | =item * |
402 | |
acbd7bdd |
403 | Debian |
404 | |
8168726b |
405 | The Debian 6 Live CD represents a great way for newcomers to experiment |
406 | with Catalyst. As a "live CD," you can simple boot from the CD, run a |
407 | few commands, and in a matter of minutes you should have a fully |
408 | function environment in which do this tutorial. B<The tutorial was fully |
409 | tested to work under Debian 6. Although it SHOULD work under any |
410 | Catalyst installation method you might choose, it can be hard to |
411 | guarantee this.> |
acbd7bdd |
412 | |
413 | =over 4 |
414 | |
415 | =item * |
416 | |
8168726b |
417 | Download one of the ISO files from |
418 | L<http://cdimage.debian.org/cdimage/release/current-live/i386/iso-hybrid/> |
419 | (the current version at the time this was written was 6.0.1). You can |
420 | pick any one of the live CD variations will work, but you may wish to |
421 | consider the following points: |
acbd7bdd |
422 | |
423 | =over 4 |
424 | |
425 | =item * |
426 | |
8168726b |
427 | "C<debian-live-6.0.1-i386-rescue.iso>" is probably the best all-around |
428 | option for most people because it includes many extra tools such as the |
429 | GCC compiler, therefore saving RAM (every package you need to install |
430 | when running from live CD consumes memory because RAM disk is being used |
431 | in lieu of real disk space). When initially booting under this image, |
432 | you may see some cryptic warning messages having to do with various |
433 | diagnostic tools it tries to load or enable, but you should be able to |
434 | safely ignore these. |
acbd7bdd |
435 | |
436 | =item * |
437 | |
8168726b |
438 | "C<debian-live-6.0.1-i386-standard.iso>" is a great option because of |
439 | its compact size, but you will probably need approximately 1 GB of RAM |
440 | in the computer where you will run the tutorial. Because the "standard" |
441 | live CD comes with with a minimal set of tools, we will have to install |
442 | extra packages (such as the GCC compiler), all of which will require RAM |
443 | when running from a live CD. |
acbd7bdd |
444 | |
445 | =item * |
446 | |
8168726b |
447 | The other ISO images include different flavors of X-Windows desktop |
448 | managers. You can select one of these if you don't mind the larger |
449 | download size and prefer a graphical environment. Be aware that these |
450 | disks do not come with the extra tools found on the "rescue" image, so |
451 | you will need adequate RAM to be able to install them just as you would |
452 | under the "standard" image. B<Use one of the "graphical" ISO images if |
453 | you want a graphical web browser on the same machine as where you will |
454 | run the tutorial.> (If you are using one of the non- graphical images |
455 | discussed above, you can still use a graphical web browser from another |
456 | machine and point it to your Catalyst development machine.) |
acbd7bdd |
457 | |
458 | =back |
459 | |
460 | =item * |
461 | |
462 | Boot off the CD. |
463 | |
464 | =item * |
465 | |
466 | Select "C<Live>" from the initial boot menu. |
467 | |
468 | =item * |
469 | |
6163536a |
470 | Once the system has booted to a "C<user@debian:~$>" prompt, first |
471 | install the Subversion client in case you want to check out the |
472 | completed chapter example code: |
473 | |
0ed3df53 |
474 | sudo aptitude -y install subversion |
6163536a |
475 | |
2e73e2be |
476 | If you want to be able to remotely SSH to this system, set a |
477 | password for root: |
478 | |
479 | sudo passwd |
480 | ... |
481 | |
8168726b |
482 | Then enter the following command to add the more current "unstable" |
483 | package repository so we get the latest versions of Catalyst and related |
484 | packages: |
acbd7bdd |
485 | |
486 | sudo vi /etc/apt/sources.list |
487 | |
488 | Add the following line to the bottom of this file: |
489 | |
490 | deb http://ftp.us.debian.org/debian/ unstable main |
491 | |
8168726b |
492 | If you are not familiar with VI, you can move to the bottom of this file |
493 | and press the "o" key to insert a new line and type the line above. |
494 | Then press the "Esc" key followed by a colon (":"), the letters "wq" and |
495 | then the "Enter" key. The rest of the tutorial will assume that you |
496 | know how to use some editor that is available from the Linux |
497 | command-line environment. |
acbd7bdd |
498 | |
499 | =item * |
500 | |
501 | Install Catalyst: |
502 | |
503 | sudo aptitude update |
504 | sudo aptitude -y install sqlite3 libdbd-sqlite3-perl libcatalyst-perl \ |
444d6b27 |
505 | libcatalyst-modules-perl libdbix-class-timestamp-perl \ |
2314f851 |
506 | libdatetime-format-sqlite-perl libconfig-general-perl \ |
9314188c |
507 | libhtml-formfu-model-dbic-perl libterm-readline-perl-perl \ |
195424f2 |
508 | libdbix-class-encodedcolumn-perl libperl6-junction-perl \ |
509 | libtest-pod-perl |
444d6b27 |
510 | |
511 | Let it install (normally about a 30 to 90-second operaton) and you are |
512 | done. (Note the '\' above. Depending on your environment, you might |
513 | be able to cut and paste the text as shown or need to remove the '\' |
fce83e5f |
514 | characters to that the command is all on a single line.) |
acbd7bdd |
515 | |
516 | If you are using an image other than the "rescue" ISO, you will also need |
517 | to run the following command to install additional packages: |
518 | |
519 | sudo aptitude -y install gcc make libc6-dev |
520 | |
8168726b |
521 | If you are running from the Live CD, you probably also want to free up |
acbd7bdd |
522 | some RAM disk space with the following: |
523 | |
524 | sudo aptitude clean |
525 | |
8168726b |
526 | NOTE: While the instructions above mention the Live CD because that |
527 | makes it easy for people new to Linux, you can obviously pick a |
528 | different Debian ISO image and install it to your hard drive. Although |
529 | there are many different ways to download and install Debian, the |
530 | "netinst" ISO image (such as "C<debian-500-i386-netinst.iso>" represents |
531 | a great option because it keeps your initial download small (but still |
532 | lets you install anything you want "over the network"). |
acbd7bdd |
533 | |
534 | Here are some tips if you are running from a live CD and are running |
535 | out of disk space (which really means you are running out of RAM): |
536 | |
537 | =over 4 |
538 | |
539 | =item * |
540 | |
8168726b |
541 | Always run "C<aptitude clean>" after you install new packages to delete |
542 | the original .deb files (the files installed B<by> the .deb package |
543 | B<will> remain available, just the .deb package itself is deleted). |
acbd7bdd |
544 | |
545 | =item * |
546 | |
8168726b |
547 | If you are installing modules from CPAN, you can free up some space with |
548 | "C<rm -rf /root/.cpan/*>" (change "/root/" in the previous command to |
549 | match your home directory or the location where CPAN has been configured |
550 | to perform build operations). |
acbd7bdd |
551 | |
552 | =item * |
553 | |
8168726b |
554 | If necessary, you can remove the cached package information with the |
555 | command "C<rm -f /var/lib/apt/lists/*>". You can later pull this |
acbd7bdd |
556 | information again via the command "C<aptitude update>". |
557 | |
558 | =item * |
559 | |
8168726b |
560 | You can save a small amount of space by commenting out the lines in |
561 | C</etc/apt/sources.list> that reference "deb-src" and |
562 | "security.debian.org". If you have already done an "C<aptitude update>" |
563 | with these repositories enabled, you can use the tip in the previous |
564 | bullet to free the space up (and then do another "C<aptitude update>"). |
acbd7bdd |
565 | |
566 | =item * |
567 | |
8168726b |
568 | Although you can free up space by removing packages you installed since |
569 | you last booted (check out "C<aptitude remove _pkg_name>"), don't bother |
570 | trying to remove packages already available at the time of boot. Instead |
571 | of freeing up space, it will actual I<consume> some space. (The live CD |
572 | uses these "burn in" packages right from the CD disk vs. first loading |
573 | them on the virtual RAM disk. However, if you remove them, the system |
574 | has to update various files, something that I<does> consume some space |
575 | on the virtual RAM disk.) |
acbd7bdd |
576 | |
577 | =back |
578 | |
579 | =back |
580 | |
581 | =item * |
582 | |
1def4a20 |
583 | Ubuntu |
584 | |
8168726b |
585 | Ubuntu is an extremely popular offshoot of Debian. It provides cutting |
586 | edge versions of many common tools, application and libraries in an |
587 | easy-to-run live CD configuration (and because a single download option |
588 | can be used for both live CD and install-to-disk usage, it keeps your |
589 | download options nice and simple). As with Debian 6, you should be able |
590 | to generate a fully function Catalyst environment in a matter of |
591 | minutes. Here are quick instructions on how to use Ubuntu to prepare |
592 | for the tutorial: |
d442cc9f |
593 | |
594 | =over 4 |
595 | |
596 | =item * |
597 | |
8168726b |
598 | Download the Ubuntu Desktop edition and boot from the CD and/or image |
599 | file, select your language, and then "Try Ubuntu without any changes to |
600 | your computer." |
1def4a20 |
601 | |
602 | =item * |
603 | |
8168726b |
604 | Open a terminal session (click "Applications" in the upper-left corner, |
605 | then "Accessories," then "Terminal"). |
1def4a20 |
606 | |
607 | =item * |
608 | |
609 | Add the 'universe' repositories: |
610 | |
3533daff |
611 | sudo gedit /etc/apt/sources.list |
1def4a20 |
612 | |
613 | And remove the comments from the lines under the comments about the |
614 | 'universe' repositories. |
615 | |
616 | =item * |
617 | |
618 | Install Catalyst: |
619 | |
acbd7bdd |
620 | sudo aptitude update |
621 | sudo aptitude install libdbd-sqlite3-perl libcatalyst-perl libcatalyst-modules-perl libconfig-general-perl |
1def4a20 |
622 | |
8168726b |
623 | Accept all of the dependencies. Done. |
2b75577c |
624 | |
8168726b |
625 | If you are running from the Live CD, you probably also want to free up |
2b75577c |
626 | some disk space with the following: |
627 | |
acbd7bdd |
628 | sudo aptitude clean |
2b75577c |
629 | |
8168726b |
630 | NOTE: While the instructions above mention the live CD because that |
631 | makes it easy for people new to Linux, you can obviously also use one of |
632 | the options to install Ubuntu on your drive. |
3533daff |
633 | |
1def4a20 |
634 | =back |
635 | |
636 | =item * |
637 | |
d442cc9f |
638 | Matt Trout's C<cat-install> |
639 | |
8168726b |
640 | Available at L<http://www.shadowcat.co.uk/static/cat-install>, |
641 | C<cat-install> can be a fairly painless way to get Catalyst up and |
642 | running. Just download the script from the link above and type C<perl |
643 | cat-install>. Depending on the speed of your Internet connection and |
644 | your computer, it will probably take 30 to 60 minutes to install because |
645 | it downloads, makes, compiles, and tests every module. But this is an |
646 | excellent way to automate the installation of all the latest modules |
ffeb7448 |
647 | used by Catalyst from CPAN. |
648 | |
d442cc9f |
649 | |
650 | =item * |
651 | |
ffeb7448 |
652 | Other Possibilities |
653 | |
654 | =over 4 |
655 | |
656 | =item * |
657 | |
658 | OpenBSD Packages |
659 | |
8168726b |
660 | The 2008 Advent Day 4 entry has more information on using OpenBSD |
661 | packages to quickly build a system: |
ffeb7448 |
662 | L<http://www.catalystframework.org/calendar/2008/4>. |
663 | |
664 | =item * |
d442cc9f |
665 | |
ffeb7448 |
666 | NetBSD Package Collection on Solaris |
667 | |
8168726b |
668 | The 2008 Advent Day 15 entry has more information on using C<pkgsrc> and |
669 | NetBSD packages on Solaris: |
1435672d |
670 | L<http://www.catalystframework.org/calendar/2008/15>. |
d442cc9f |
671 | |
672 | =item * |
673 | |
ffeb7448 |
674 | CatInABox |
675 | |
8168726b |
676 | You can get more information at |
677 | L<http://www.catalystframework.org/calendar/2008/7> or |
678 | L<Perl::Dist::CatInABox|Perl::Dist::CatInABox>. |
ffeb7448 |
679 | |
0c51850e |
680 | =item * |
681 | |
682 | Frank Speiser's Amazon EC2 Catalyst SDK |
683 | |
684 | There are currently two flavors of publicly available Amazon Machine |
685 | Images (AMI) that include all the elements you'd need to begin |
686 | developing in a fully functional Catalyst environment within minutes. |
687 | See L<Catalyst::Manual::Installation|Catalyst::Manual::Installation> |
688 | for more details. |
689 | |
d442cc9f |
690 | =back |
691 | |
ffeb7448 |
692 | =back |
693 | |
d442cc9f |
694 | For additional information and recommendations on Catalyst installation, |
8168726b |
695 | please refer to |
d442cc9f |
696 | L<Catalyst::Manual::Installation|Catalyst::Manual::Installation>. |
697 | |
1390ef0e |
698 | |
d442cc9f |
699 | =head1 DATABASES |
700 | |
701 | This tutorial will primarily focus on SQLite because of its simplicity |
702 | of installation and use; however, modifications in the script required |
acbd7bdd |
703 | to support MySQL and PostgreSQL will be presented in Appendix. |
d442cc9f |
704 | |
705 | B<Note:> One of the advantages of the MVC design patterns is that |
706 | applications become much more database independent. As such, you will |
707 | notice that only the C<.sql> files used to initialize the database |
708 | change between database systems: the Catalyst code generally remains the |
709 | same. |
710 | |
1390ef0e |
711 | |
d442cc9f |
712 | =head1 WHERE TO GET WORKING CODE |
713 | |
8168726b |
714 | Each chapter of the tutorial has complete code available as a tarball in |
715 | the main Catalyst Subversion repository (see the note at the beginning |
028b4e1a |
716 | of each part for the appropriate svn command to use). |
d442cc9f |
717 | |
8168726b |
718 | B<NOTE:> You can run the test cases for the final code through Chapter 8 |
028b4e1a |
719 | with the following commands: |
d442cc9f |
720 | |
0ed3df53 |
721 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter8 |
722 | cd MyApp_Chapter8/MyApp |
96a87356 |
723 | CATALYST_DEBUG=0 prove -wl t |
d442cc9f |
724 | |
96a87356 |
725 | If you wish to include the L<HTML::FormFu|HTML::FormFu> section in your tests, |
6163536a |
726 | substitute C<MyApp_Chapter9_FormFu> for C<MyApp_Chapter8> in the URL |
727 | above (don't forget to "cd" out of the Ch8 directory if you ran the code above). |
acbd7bdd |
728 | |
0ed3df53 |
729 | svn co http://dev.catalystframework.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter9_FormFu |
730 | cd MyApp_Chapter9_FormFu/MyApp |
96a87356 |
731 | CATALYST_DEBUG=0 prove -wl t |
acbd7bdd |
732 | |
733 | You can also fire up the application under the development server that is conveniently |
734 | built in to Catalyst. Just issue this command from the C<MyApp> directory where you |
735 | ran the test suite above: |
736 | |
737 | script/myapp_server.pl |
738 | |
8168726b |
739 | And the application will start. You can try out the application by |
740 | pulling up C<http://localhost:3000> in your web browser (as mentioned |
741 | earlier, change C<localhost> to a different IP address or DNS name if |
742 | you are running your web browser and your Catalyst development on |
743 | different boxes). We will obviously see more about how to use the |
744 | application as we go through the remaining chapters of the tutorial, but |
745 | for now you can log in using the username "test01" and a password of |
acbd7bdd |
746 | "mypass". |
747 | |
d442cc9f |
748 | |
749 | =head1 AUTHOR |
750 | |
751 | Kennedy Clark, C<hkclark@gmail.com> |
752 | |
8168726b |
753 | Please report any errors, issues or suggestions to the author. The |
754 | most recent version of the Catalyst Tutorial can be found at |
59884771 |
755 | L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>. |
d442cc9f |
756 | |
ec3ef4ad |
757 | Copyright 2006-2010, Kennedy Clark, under the |
758 | Creative Commons Attribution Share-Alike License Version 3.0 |
865d3efb |
759 | (L<http://creativecommons.org/licenses/by-sa/3.0/us/>). |