X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=9f39c49baa5decfd4ff6c915472a64e3526df450;hb=75c0ec035b7fdca765a41974a7970bf170b273d0;hp=21a701d22b509352faa6b6a0b1986cab53cb43d5;hpb=5882c86e1f256e122583dcc311b17bdbf9a4d766;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 21a701d..9f39c49 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -34,8 +34,8 @@ modify code that handles one concern without affecting code that handles the others. Catalyst promotes the re-use of existing Perl modules that already handle common web application concerns well. -Here's how the M, V, and C map to those concerns, with examples of -well-known Perl modules you may want to use for each. +Here's how the Model, View, and Controller map to those concerns, with +examples of well-known Perl modules you may want to use for each. =over 4 @@ -64,9 +64,8 @@ is becoming a popular design method for web applications. =head3 Flexibility -Catalyst is much more flexible than many other frameworks. We'll talk -more about this later, but rest assured you can use your favorite Perl -modules with Catalyst. +Catalyst is much more flexible than many other frameworks. Rest assured +you can use your favorite Perl modules with Catalyst. =over 4 @@ -104,9 +103,10 @@ example: Now http://localhost:3000/hello prints "Hello World!". -=item * B +=item * B -Use L or L. +Use L or L. Other +engines are also available. =back @@ -144,7 +144,8 @@ framework, making it easy to test applications from the command line. =item * B Catalyst provides helper scripts to quickly generate running starter -code for components and unit tests. See L. +code for components and unit tests. Install L and see +L. =back @@ -155,7 +156,14 @@ running, using the helper scripts described above. =head3 Install - $ perl -MCPAN -e 'install Task::Catalyst' +Installation of Catalyst can be a time-consuming and frustrating +effort, due to its large number of dependencies. The easiest way +to get up and running is to use Matt Trout's C +script, from L, +and then install L. + + # perl cat-install + # perl -MCPAN -e 'install Catalyst::Devel' =head3 Setup @@ -183,465 +191,740 @@ 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/; + 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 #####, 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. -###### We need a short section on configuration here. +=head4 Views -=head3 Context +To show how to define views, we'll use an already-existing base class for the +L