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