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