From: Jesse Sheidlower Date: Thu, 6 Jul 2006 04:34:17 +0000 (+0000) Subject: Rearrangement of Intro.pod X-Git-Tag: 5.7099_04~425 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=75c0ec035b7fdca765a41974a7970bf170b273d0 Rearrangement of Intro.pod --- diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 39cf95e..9f39c49 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -191,509 +191,467 @@ Both of these URLs should take you to the welcome page.) =back -Easy! - =head2 How It Works Let's see how Catalyst works, by taking a closer look at the components and other parts of a Catalyst application. -=head3 Application Class +=head3 Components -In addition to the Model, View, and Controller components, there's a -single class that represents your application itself. This is where you -configure your application, load plugins, and extend Catalyst. +Catalyst has an uncommonly flexible component system. You can define as +many L, L, and L as you like. As discussed +previously, the general idea is that the View is responsible for the +output of data to the user (typically via a web browser, but a View can +also generate PDFs or e-mails, for example); the Model is responsible +for providing data (typically from a relational database); and the +Controller is responsible for interacting with the user and deciding +how user input determines what actions the application takes. + +In the world of MVC, there are frequent discussions and disagreements +about the nature of each element - whether certain types of logic +belong in the Model or the Controller, etc. Catalyst's flexibility +means that this decision is entirely up to you, the programmer; +Catalyst doesn't enforce anything. See L for +a general discussion of these concerns. - package MyApp; +All components must inherit from L, which provides a +simple class structure and some common class methods like C and +C (constructor). + + package MyApp::Controller::Catalog; use strict; - use Catalyst qw/-Debug/; # Add other plugins here, e.g. - # for session support + use base 'Catalyst::Base'; - MyApp->config( - name => 'My Application', + __PACKAGE__->config( foo => 'bar' ); - # You can put anything else you want in here: - my_configuration_variable => 'something', - ); 1; -In older versions of Catalyst, the application class was where you put -global actions. However, as of version 5.66, the recommended practice is -to place such actions in a special Root controller (see L, -below), to avoid namespace collisions. +You don't have to C or otherwise register Models, Views, and +Controllers. Catalyst automatically discovers and instantiates them +when you call C in the main application. All you need to do is +put them in directories named for each Component type. You can use a +short alias for each one. =over 4 -=item * B +=item * B -The name of your application. +=item * B + +=item * B + +=item * B + +=item * B + +=item * B =back -Optionally, you can specify a B parameter for templates and static -data. If omitted, Catalyst will try to auto-detect the directory's -location. You can define as many parameters as you want for plugins or -whatever you need. You can access them anywhere in your application via -C<$context-Econfig-E{$param_name}>. +In older versions of Catalyst, the recommended practice (and the one +automatically created by helper scripts) was to name the directories +C, C, and C. Though these still work, we now recommend +the use of the full names. -=head3 Context +=head4 Views -Catalyst automatically blesses a Context object into your application -class and makes it available everywhere in your application. Use the -Context to directly interact with Catalyst and glue your L -together. For example, if you need to use the Context from within a -Template Toolkit template, it's already there: +To show how to define views, we'll use an already-existing base class for the +L