X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FCatalystBasics.pod;h=7096679d5957c06440cf3bf5a6af81def9a07a43;hb=c9b77c06a0de97f1d6e9a66091e693a637578357;hp=65fd1d687477afff682cc2ba6f25fd1f53c1b5ba;hpb=64ccd8a8bfbc16276c044c94702b1440c2897695;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod index 65fd1d6..7096679 100644 --- a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod @@ -3,7 +3,6 @@ Catalyst::Manual::Tutorial::CatalystBasics - Catalyst Tutorial - Part 2: Catalyst Application Development Basics - =head1 OVERVIEW This is B for the Catalyst tutorial. @@ -22,7 +21,7 @@ B =item 3 -L +L =item 4 @@ -42,16 +41,15 @@ L =item 8 -L +L =item 9 -L +L =back - =head1 DESCRIPTION In this part of the tutorial, we will create a very basic Catalyst web @@ -69,24 +67,26 @@ skeletal structure of an application. Model/View/Controller (MVC) provides an architecture that facilitates a clean "separation of control" between the different portions of your -application. Given that many other documents cover this subject in +application. Given that many other documents cover this subject in detail, MVC will not be discussed in depth here (for an excellent introduction to MVC and general Catalyst concepts, please see -L. In short: +L. In short: =over 4 =item * Model -In most applications, the model equates to the objects that are created -from and saved to your SQL database. +The model usually represents a data store. In most applications, the +model equates to the objects that are created from and saved to your SQL +database. =item * View The view takes model objects and renders them into something for the end -user to look at. Normally this involves a template-generation tool that +user to look at. Normally this involves a template-generation tool that creates HTML for the user's web browser, but it could easily be code -that generates other forms such as PDF documents or Excel spreadsheets. +that generates other forms such as PDF documents, e-mails, or Excel +spreadsheets. =item * Controller @@ -97,9 +97,9 @@ them to the necessary model and view. =item * ORM -The use Object-Relational Mapping (ORM) technology for database access -(specifically, ORM provides an automated means to persist and restore -objects to/from a relational database). +The use of Object-Relational Mapping (ORM) technology for database +access. Specifically, ORM provides an automated and standardized means +to persist and restore objects to/from a relational database. =back @@ -107,37 +107,80 @@ B: Note that all of the code for this part of the tutorial can be pulled from the Catalyst Subversion repository in one step with the following command: - svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial@### - IMPORTANT: Does not work yet. Will be completed for final version. - + svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/CatalystBasics MyApp =head1 CREATE A CATALYST PROJECT Catalyst provides a number of helper scripts that can be used to quickly -flesh out the basic structure of your application. All Catalyst -projects begin with the C helper. +flesh out the basic structure of your application. All Catalyst projects +begin with the C helper. In the case of this tutorial, use the Catalyst C script to initialize the framework for an application called C: $ catalyst.pl MyApp + created "MyApp" + created "MyApp/script" + created "MyApp/lib" + created "MyApp/root" + ... + created "MyApp/script/myapp_create.pl" $ cd MyApp The C helper script will display the names of the directories and files it creates. -Though it's obviously too early for any significant celebration, we -already have a functioning application. Run the following command to -run this application with the built-in development web server: +Though it's too early for any significant celebration, we already have a +functioning application. Run the following command to run this +application with the built-in development web server: - $ script/myapp_server.pl + $ script/myapp_server.pl + [debug] Debug messages enabled + [debug] Loaded plugins: + .----------------------------------------------------------------------------. + | Catalyst::Plugin::ConfigLoader 0.06 | + | Catalyst::Plugin::Static::Simple 0.14 | + '----------------------------------------------------------------------------' + + [debug] Loaded dispatcher "Catalyst::Dispatcher" + [debug] Loaded engine "Catalyst::Engine::HTTP" + [debug] Found home "/root/dev/MyApp" + [debug] Loaded components: + .-----------------------------------------------------------------+----------. + | Class | Type | + +-----------------------------------------------------------------+----------+ + | MyApp::Controller::Root | instance | + '-----------------------------------------------------------------+----------' + + [debug] Loaded Private actions: + .----------------------+--------------------------------------+--------------. + | Private | Class | Method | + +----------------------+--------------------------------------+--------------+ + | /default | MyApp::Controller::Root | default | + | /end | MyApp::Controller::Root | end | + '----------------------+--------------------------------------+--------------' + + [info] MyApp powered by Catalyst 5.7000 + You can connect to your server at http://localhost.localdomain:3000 + +Point your web browser to L (substituting a +different hostname or IP address as appropriate) and you should be +greeted by the Catalyst welcome screen. Information similar to the +following should be appended to the logging output of the development +server: -Point your web browser to L (substituting a -different hostname or IP address as appropriate) and you should be -greeted by the Catalyst welcome screen. Press Ctrl-C to break out of -the development server. + [info] *** Request 1 (0.043/s) [6003] [Fri Jul 7 13:32:53 2006] *** + [debug] "GET" request for "/" from "127.0.0.1" + [info] Request took 0.067675s (14.777/s) + .----------------------------------------------------------------+-----------. + | Action | Time | + +----------------------------------------------------------------+-----------+ + | /default | 0.002844s | + | /end | 0.000207s | + '----------------------------------------------------------------+-----------' +Press Ctrl-C to break out of the development server. =head1 CREATE A SQLITE DATABASE @@ -191,7 +234,7 @@ in your editor and enter: INSERT INTO book_authors VALUES (5, 8); B: See Appendix 1 for tips on removing the leading spaces when -cutting and pasting example code from Pod documents. +cutting and pasting example code from POD-based documents. Then use the following command to build a C SQLite database: @@ -233,7 +276,6 @@ required if you do a single SQL statement on the command line). Use your OS command prompt. - =head1 EDIT THE LIST OF CATALYST PLUGINS One of the greatest benefits of Catalyst is that it has such a large @@ -258,7 +300,9 @@ this plugin when you place your application into production. As you may have noticed, C<-Debug> is not a plugin, but a I. Although most of the items specified on the C line of your application class will be plugins, Catalyst supports a limited number of -flag options (of these, C<-Debug> is the most common). +flag options (of these, C<-Debug> is the most common). See the +documentation for C to get details on other flags +(currently C<-Engine>, C<-Home>, and C<-Log>). If you prefer, you can use the C<$c-Edebug> method to enable debug messages. @@ -267,7 +311,7 @@ messages. L -C provides an automatic way to load your configurable +C provides an automatic way to load configurable parameters for your application from a central YAML file (versus having the values hard-coded inside your Perl modules). If you have not been exposed to YAML before, it is a human-readable data serialization format @@ -275,7 +319,6 @@ that can be used to read (and write) values to/from text files. We will see how to use this feature of Catalyst during the authentication and authorization sections (Part 4 and Part 5). - =item * L @@ -298,91 +341,69 @@ Replace it with: ConfigLoader Static::Simple - Dumper StackTrace - DefaultEnd /; -This tells Catalyst to start using three new plugins: +This tells Catalyst to start using one new plugin: =over 4 =item * -L - -Allows you to easily use L to dump variables -to the logs, for example: - - $c->log->dumper($myvar); - -When running your application under the development server, the logs -will be printed to your screen along with the other debug information -generated by the C<-Debug> flag. - -=item * - L Adds a stack trace to the standard Catalyst "debug screen" (this is the screen Catalyst sends to your browser when an error occurs). -Note: L output appears on the -console/telnet/SSH window where you issue the C