initial import of new Tutorial stuff from hkclark
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Manual / Tutorial / Intro.pod
1 =head1 NAME
2
3 Catalyst::Manual::Tutorial::Intro - Catalyst Tutorial – Part 1: Introduction
4
5
6
7 =head1 OVERVIEW
8
9 This is B<Part 1 of 9> for the Catalyst tutorial.
10
11 L<Totorial Overview|Catalyst::Manual::Tutorial>
12
13 =over 4
14
15 =item 1
16
17 B<Introduction>
18
19 =item 2
20
21 L<Catalyst Basics|Catalyst::Manual::Tutorial::CatalystBasics>
22
23 =item 3
24
25 L<Basic CRUD|Catalyst::Manual::Tutorial03_BasicCRUD>
26
27 =item 4
28
29 L<Authentication|Catalyst::Manual::Tutorial::Authentication>
30
31 =item 5
32
33 L<Authorization|Catalyst::Manual::Tutorial::Authorization>
34
35 =item 6
36
37 L<Debugging|Catalyst::Manual::Tutorial::Debugging>
38
39 =item 7
40
41 L<Testing|Catalyst::Manual::Tutorial::Testing>
42
43 =item 8
44
45 L<AdvancedCRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
46
47 =item 9
48
49 L<Appendicies|Catalyst::Manual::Tutorial::Appendicies>
50
51 =back
52
53
54
55 =head1 DESCRIPTION
56
57 This tutorial provides a nine-part introduction to the Catalyst web framework.  It seeks to provide a rapid overview of many of its most commonly used features.  The focus is on the real-world best practices required in the construction of nearly all Catalyst applications.
58
59 Although the primary target of the tutorial is users new to the Catalyst framework, experienced users may wish to review specific sections (for example, how to use DBIC for their model classes or how to add authentication and authorization to an existing application).
60
61 Subjects covered include:
62
63 =over 4
64
65 =item * 
66
67 A simple application that lists and adds books.
68
69 =item *
70
71 The use of C<DBIx::Class> (DBIC) for the model.
72
73 =item * 
74
75 How to write CRUD (Create, Read, Update and Delete) operations in Catalyst.
76
77 =item *
78
79 Authentication ("auth").
80
81 =item * 
82
83 Role-based authorization ("authz").
84
85 =item * 
86
87 Attempts to provide an example showing current Catalyst 5.70 practices. For example, the use of C<Catalyst::Plugin::DefaultEnd>, DBIC, C<Catalyst::Plugin::ConfigLoader> with myapp.yml, the use of C<lib/MyApp/Controller/Root.pm> vs. C<lib/MyApp.pm>, etc.
88
89 =item * 
90
91 The use of Template Toolkit (TT) and the C<Catalyst::Helper::View::TTSite> view helper.
92
93 =item * 
94
95 Useful techniques for troubleshooting and debugging Catalyst applications.
96
97 =item * 
98
99 The use of SQLite as a database (with code also provided for MySQL and PostgreSQL).
100
101 =item * 
102
103 How to use HTML::Widget for automated form processing and validation.
104
105 =back
106
107 This tutorial intentionally seeks to make the learning process its main priority.  For example, the level of comments in the code found here would like be considered excessive in a "normal project".  Because of their contextual value, this tutorial will generally favor inline comments over a separate discussion in the text.  It also deliberately tries to demonstrate multiple approaches to various features (in general, you should try to be as consistent as possible with your own production code).
108
109 Furthermore, this tutorial tries to minimize the number of controllers, models, TT templates, and database tables.  Although this does result in things being a bit contrived at times, the concepts should be applicable to more complex environments.  More complete and complicated example applications can be found in the C<examples> area of the Catalyst Subversion repository at L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/>.
110
111 B<Note:> There are a variety of other introductory materials available through the Catalyst web site and at L<http://dev.catalyst.perl.org/wiki/UserIntroductions> and L<http://dev.catalyst.perl.org/>.
112
113
114
115 =head1 VERSIONS AND CONVENTIONS USED IN THIS TUTORIAL
116
117 This tutorial was built using the following resources.  Please note that you will need to make adjustments for different environments and versions:
118
119 =over 4
120
121 =item * 
122
123 OS = CentOS 4 Linux (RHEL 4)
124
125 =item * 
126
127 Catalyst v5.67
128
129 =item * 
130
131 DBIx::Class v0.06002
132
133 =item * 
134
135 Catalyst Plugins
136
137 You shouldn't be overly concerned about plugin version numbers, but there could be cases where the tutorial is impacted by what version plugins you use.  The plugins used in this tutorial are:
138
139 =over 4
140
141 =item * 
142
143 Catalyst::Plugin::Authentication -- 0.07
144
145 =item *
146
147 Authentication::Credential::Password -- 0.07
148
149 =item *
150
151 Catalyst::Plugin::Authentication::Store::DBIC -- 0.06
152
153 =item *
154
155 Catalyst::Plugin::Authorization::ACL -- 0.06
156
157 =item *
158
159 Catalyst::Plugin::Authorization::Roles -- 0.04
160
161 =item *
162
163 Catalyst::Plugin::ConfigLoader -- 0.07
164
165 =item *
166
167 Catalyst::Plugin::DefaultEnd -- 0.06
168
169 =item *
170
171 Catalyst::Plugin::Dumper -- 0.000002
172
173 =item *
174
175 Catalyst::Plugin::HTML::Widget -- 1.1
176
177 =item *
178
179 Catalyst::Plugin::Session -- 0.05
180
181 =item *
182
183 Catalyst::Plugin::Session::FastMmap -- 0.12
184
185 =item *
186
187 Catalyst::Plugin::Session::State::Cookie -- 0.02
188
189 =item *
190
191 Catalyst::Plugin::Session::Store::FastMmap -- 0.0
192
193 =item *
194
195 Catalyst::Plugin::StackTrace -- 0.0
196
197 =item *
198
199 Catalyst::Plugin::Static::Simple -- 0.14
200
201 =back
202
203 =item * 
204
205 Since the web browser is being used on the same box where Perl and the Catalyst development server is running, the URL of C<http://localhost:3000> will be used (the Catalyst development server defaults to port 3000).  If you are running Perl on a different box than where your web browser is located (or using a different port number via the C<-p> I<port_number> option to the development server), then you will need to update the URL you use accordingly.
206
207 =item * 
208
209 Depending on the web browser you are using, you might need to hit C<Shift+Reload> to pull a fresh page when testing your application at various points.  Also, the C<-k> keepalive option to the development server can be necessary with some browsers (especially Internet Explorer).
210
211 =back
212
213
214
215 =head1 CATALYST INSTALLATION
216
217 Unfortunately, one of the most daunting tasks faced by newcomers to Catalyst is getting it installed.  Although a compelling strength of Catalyst is that it can easily make full use of CPAN, a vast repository of Perl modules, this can result in initial installations that are both time consuming and frustrating.  However, there are a growing number of methods that can dramatically ease this undertaking.  Of these, the following are likely to be applicable to the largest number of potential new users:
218
219 =over 4
220
221 =item * 
222
223 Matt Trout’s C<cat-install>
224
225 Available at L<http://www.shadowcatsystems.co.uk/static/cat-install>, C<cat-install> can be a quick and painless way to get Catalyst up and running.  Just download the script from the link above and type C<perl cat-install>.
226
227 =item * 
228
229 Chris Laco's CatInABox
230
231 Download the tarball from L<http://handelframework.com/downloads/CatInABox.tar.gz> and unpack it on your machine.  Depending on your OS platform, either run C<start.bat> or C<start.sh>.
232
233 =item * 
234
235 Pre-Built VMWare Images
236
237 Under the VMWare community program, work is ongoing to develop a number of VMWare images where an entire Catalyst development environment has already been installed, complete with database engines and a full complement of Catalyst plugins.
238
239 =back
240
241 B<IMPORTANT:> For additional information and recommendations on Catalyst installation, please refer to L<Catalyst::Manual::Installation|Catalyst::Manual::Installation>.
242
243 B<IMPORTANT:> Step-by-step instructions to replicate the environment on which this tutorial was developed can be found at L<Catalyst::Manual::Installation::CentOSTuorial|Catalyst::Manual::Installation::CentOSTuorial>.  Using these instructions, you should be able to build a complete CentOS 4.X server with Catalyst and all the plugins required to run this tutorial.
244
245
246
247 =head1 DATABASES
248
249 This tutorial will primarily focus on SQLite because of its simplicity; however, modifications in the script required to support MySQL and PostgreSQL will be presented in Appendix 2.
250
251 B<Note:> One of the advantages of the MVC design patterns is that applications become much more database independent.  As such, you will notice that only the C<.sql> files used to initialize the database change between database systems... the Catalyst code generally remains the same.
252
253
254
255 =head1 WHERE TO GET WORKING CODE
256
257 Each part of the tutorial has complete code available in the main Catalyst Subversion repository (see the note at the beginning of each part for the appropriate svn command to use).  Additionally, the final code is available as a ready-to-run tarball at TO_BE_ADDED_TO_FINAL_VERSION.
258
259
260
261 =head1 AUTHOR
262
263 Kennedy Clark, C<hkclark@gmail.com>
264
265 Please report any errors, issues or suggestions to the author.
266
267 Copyright 2006, Kennedy Clark, under Creative Commons License (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).
268
269 Version: .94
270