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