Fix typo in Intro.pod & add new header to AdvancedCRUD.pod
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Tutorial / Intro.pod
CommitLineData
d442cc9f 1=head1 NAME
2
3Catalyst::Manual::Tutorial::Intro - Catalyst Tutorial - Part 1: Introduction
4
5
6=head1 OVERVIEW
7
50211f3c 8This is B<Part 1 of 10> for the Catalyst tutorial.
d442cc9f 9
10L<Tutorial Overview|Catalyst::Manual::Tutorial>
11
12=over 4
13
14=item 1
15
16B<Introduction>
17
18=item 2
19
20L<Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
21
22=item 3
23
1def4a20 24L<More Catalyst Basics|Catalyst::Manual::Tutorial::MoreCatalystBasics>
d442cc9f 25
26=item 4
27
1def4a20 28L<Basic CRUD|Catalyst::Manual::Tutorial::BasicCRUD>
d442cc9f 29
30=item 5
31
1def4a20 32L<Authentication|Catalyst::Manual::Tutorial::Authentication>
d442cc9f 33
34=item 6
35
1def4a20 36L<Authorization|Catalyst::Manual::Tutorial::Authorization>
d442cc9f 37
38=item 7
39
1def4a20 40L<Debugging|Catalyst::Manual::Tutorial::Debugging>
d442cc9f 41
42=item 8
43
1def4a20 44L<Testing|Catalyst::Manual::Tutorial::Testing>
d442cc9f 45
46=item 9
47
1def4a20 48L<Advanced CRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
49
50=item 10
51
d442cc9f 52L<Appendices|Catalyst::Manual::Tutorial::Appendices>
53
54=back
55
1def4a20 56
d442cc9f 57=head1 DESCRIPTION
58
59This tutorial provides a multipart introduction to the Catalyst web
60framework. It seeks to provide a rapid overview of many of its most
61commonly used features. The focus is on the real-world best practices
62required in the construction of nearly all Catalyst applications.
63
64Although the primary target of the tutorial is users new to the Catalyst
65framework, experienced users may wish to review specific sections (for
1def4a20 66example, how to use DBIC for their model classes, how to add
67authentication and authorization to an existing application, or form
68management).
d442cc9f 69
70You can obtain the code for all the tutorial examples from the
71catalyst subversion repository by issuing the command:
72
73 svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/ CatalystTutorial
74
75This will download the current code for each tutorial chapter in the
76CatalystTutorial directory. Each example application directory has
77the same name as the tutorial chapter.
78
3d9ae335 79B<These reference implementations are provided so that when you follow
80the tutorial, you can use the code from the subversion repository to
81ensure that your system is set up correctly, and that you have not
82inadvertently made any typographic errors, or accidentally skipped
83part of the tutorial.>
84
d442cc9f 85Additionally, if you're reading this manual online, you can download
3dcf2e2c 86the example program and all the necessary dependencies to
d442cc9f 87your local machine by installing the C<Task::Catalyst::Tutorial>
88distribution from CPAN:
89
90 cpan Task::Catalyst::Tutorial
91
92This will also test to make sure the dependencies are working. If you
93have trouble installing these, please ask for help on the #catalyst
94IRC channel, or the Catalyst mailing list.
95
96Subjects covered include:
97
98=over 4
99
100=item *
101
102A simple application that lists and adds books.
103
104=item *
105
106The use of L<DBIx::Class|DBIx::Class> (DBIC) for the model.
107
108=item *
109
110How to write CRUD (Create, Read, Update, and Delete) operations in
111Catalyst.
112
113=item *
114
115Authentication ("auth").
116
117=item *
118
119Role-based authorization ("authz").
120
121=item *
122
123Attempts to provide an example showing current (5.7XXX) Catalyst
124practices. For example, the use of
125L<Catalyst::Action::RenderView|Catalyst::Action::RenderView>,
126DBIC, L<Catalyst::Plugin::ConfigLoader|Catalyst::Plugin::ConfigLoader>
127with C<myapp.yml>, the use of C<lib/MyApp/Controller/Root.pm>
128vs. C<lib/MyApp.pm>, etc.
129
130=item *
131
132The use of Template Toolkit (TT) and the
133L<Catalyst::Helper::View::TTSite|Catalyst::Helper::View::TTSite>
134view helper.
135
136=item *
137
138Useful techniques for troubleshooting and debugging Catalyst
139applications.
140
141=item *
142
143The use of SQLite as a database (with code also provided for MySQL and
144PostgreSQL).
145
146=item *
147
1def4a20 148The use of L<HTML::FormFu|HTML::FormFu> for automated form processing
d442cc9f 149and validation.
150
151=back
152
153This tutorial makes the learning process its main priority. For
154example, the level of comments in the code found here would likely be
1def4a20 155considered excessive in a "normal project." Because of their contextual
d442cc9f 156value, this tutorial will generally favor inline comments over a
157separate discussion in the text. It also deliberately tries to
158demonstrate multiple approaches to various features (in general, you
159should try to be as consistent as possible with your own production
160code).
161
162Furthermore, this tutorial tries to minimize the number of controllers,
163models, TT templates, and database tables. Although this does result in
164things being a bit contrived at times, the concepts should be applicable
165to more complex environments. More complete and complicated example
166applications can be found in the C<examples> area of the Catalyst
167Subversion repository at
168L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/>.
169
170B<Note:> There are a variety of other introductory materials available
171through the Catalyst web site and at
172L<http://dev.catalyst.perl.org/wiki/UserIntroductions> and
173L<http://dev.catalyst.perl.org/>.
174
175=head1 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
176
177This tutorial was built using the following resources. Please note that
178you may need to make adjustments for different environments and
179versions:
180
181=over 4
182
183=item *
184
1def4a20 185Ubuntu 8.04 Hardy Heron
d442cc9f 186
187=item *
188
1def4a20 189Catalyst v5.7011
dd88c3b6 190
22a67212 191=item *
dd88c3b6 192
1def4a20 193Catalyst::Devel v1.03
d442cc9f 194
195=item *
196
1def4a20 197DBIx::Class v0.08008
d442cc9f 198
199=item *
200
201Catalyst Plugins
202
203The plugins used in this tutorial all have sufficiently stable APIs that
204you shouldn't need to worry about versions. However, there could be
205cases where the tutorial is affected by what version of plugins you
206use. This tutorial has been tested against the following set of plugins:
207
208=over 4
209
210=item *
211
1def4a20 212Catalyst::Plugin::Authentication -- v0.10002
d442cc9f 213
214=item *
215
1def4a20 216Catalyst::Plugin::Authentication::Store::DBIC -- v0.09
d442cc9f 217
218=item *
219
1def4a20 220Catalyst::Plugin::Authorization::ACL -- v0.08
d442cc9f 221
222=item *
223
1def4a20 224Catalyst::Plugin::Authorization::Roles -- v0.05
d442cc9f 225
226=item *
227
1def4a20 228Catalyst::Plugin::ConfigLoader -- v0.17
d442cc9f 229
230=item *
231
1def4a20 232Catalyst::Plugin::Session -- v0.18
d442cc9f 233
234=item *
235
1def4a20 236Catalyst::Plugin::Session::State::Cookie -- v0.08
d442cc9f 237
238=item *
239
1def4a20 240Catalyst::Plugin::Session::Store::FastMmap -- v0.03
d442cc9f 241
242=item *
243
1def4a20 244Catalyst::Plugin::StackTrace -- v0.06
d442cc9f 245
246=item *
247
1def4a20 248Catalyst::Plugin::Static::Simple -- v0.20
d442cc9f 249
250=back
251
252=item *
253
254Since the web browser is being used on the same box where Perl and the
255Catalyst development server is running, the URL of
256C<http://localhost:3000> will be used (the Catalyst development server
257defaults to port 3000). If you are running Perl on a different box than
258where your web browser is located (or using a different port number via
259the C<-p> I<port_number> option to the development server), then you
260will need to update the URL you use accordingly.
261
262=item *
263
264Depending on the web browser you are using, you might need to hit
265C<Shift+Reload> to pull a fresh page when testing your application at
266various points. Also, the C<-k> keepalive option to the development
267server can be necessary with some browsers (especially Internet
268Explorer).
269
270=back
271
272=head1 CATALYST INSTALLATION
273
1def4a20 274If approach in the wrong manner, it can be a daunting tasks to get
275Catalyst initally installed. Although a compelling strength of
276Catalyst is that it makes use of many of the modules in the
277vast repository that is CPAN, this can complicate the installation
278process. However, there are a growing number of methods
279that can dramatically ease this undertaking. Of these, the following
280are likely to be applicable to the largest number of potential new
281users:
282
283=over 4
284
285=item *
286
287Ubuntu
288
289Given the popularity of Ubuntu and it's ease of use, Ubuntu can be
290a great way for newcomers to experiment with Catalyst. Because it
291is a "live CD," you can simply boot from the CD, run a few commands,
292and you should have a fully functional environment in which to do
293this tutorial in a matter of minutes.
d442cc9f 294
295=over 4
296
297=item *
298
1def4a20 299Download Ubuntu 8.04 (aka, Hardy Heron) and boot from the CD and/or
300image file, select your language, and then "Try Ubuntu without any
301changes to your computer."
302
303=item *
304
305Open a terminal session.
306
307=item *
308
309Add the 'universe' repositories:
310
311 sudo vi /etc/apt/sources.list
312
313And remove the comments from the lines under the comments about the
314'universe' repositories.
315
316=item *
317
318Install Catalyst:
319
320 sudo apt-get update
321 sudo apt-get upgrade
322 sudo apt-get install sqlite3 libdbd-sqlite3-perl libcatalyst-perl libcatalyst-modules-perl
323
324Accept all of the dependencies. Done.
325
326=back
327
328=item *
329
d442cc9f 330Matt Trout's C<cat-install>
331
332Available at L<http://www.shadowcatsystems.co.uk/static/cat-install>,
333C<cat-install> can be a quick and painless way to get Catalyst up and
334running. Just download the script from the link above and type C<perl
335cat-install>.
336
337=item *
338
339Chris Laco's CatInABox
340
341Download the tarball from
342L<http://handelframework.com/downloads/CatInABox.tar.gz> and unpack it
343on your machine. Depending on your OS platform, either run C<start.bat>
344or C<start.sh>.
345
346=item *
347
348Pre-Built VMWare Images
349
350Under the VMWare community program, work is ongoing to develop a number
351of VMWare images where an entire Catalyst development environment has
352already been installed, complete with database engines and a full
353complement of Catalyst plugins.
354
355=back
356
357For additional information and recommendations on Catalyst installation,
358please refer to
359L<Catalyst::Manual::Installation|Catalyst::Manual::Installation>.
360
361B<NOTE:> Step-by-step instructions to replicate the environment on
362which this tutorial was developed can be found at
363L<Catalyst::Manual::Installation::CentOS4|Catalyst::Manual::Installation::CentOS4>.
364Using these instructions, you should be able to build a complete CentOS
3654.X server with Catalyst and all the plugins required to run this
366tutorial.
367
368=head1 DATABASES
369
370This tutorial will primarily focus on SQLite because of its simplicity
371of installation and use; however, modifications in the script required
372to support MySQL and PostgreSQL will be presented in Appendix 2.
373
374B<Note:> One of the advantages of the MVC design patterns is that
375applications become much more database independent. As such, you will
376notice that only the C<.sql> files used to initialize the database
377change between database systems: the Catalyst code generally remains the
378same.
379
380=head1 WHERE TO GET WORKING CODE
381
382Each part of the tutorial has complete code available in the main
383Catalyst Subversion repository (see the note at the beginning of each
384part for the appropriate svn command to use). Additionally, the final
385code is available as a ready-to-run tarball at
386L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz>.
387
388B<NOTE:> You can run the test cases for the final code with the following
389commands:
390
391 wget http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/Final_Tarball/MyApp.tgz
392 tar zxvf MyApp.tgz
393 cd MyApp
394 CATALYST_DEBUG=0 prove --lib lib t
395
396
397=head1 AUTHOR
398
399Kennedy Clark, C<hkclark@gmail.com>
400
401Please report any errors, issues or suggestions to the author. The
402most recent version of the Catalyst Tutorial can be found at
d712b826 403L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
d442cc9f 404
405Copyright 2006, Kennedy Clark, under Creative Commons License
406(L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).
407
408