=head3 MVC
-Catalyst follows the Model-View-Controller (MVC) design pattern, allowing you to easily separate concerns, like content, presentation and flow control, into separate modules. This separation allows you to modify code tat handles one concern without affecting code that handles the others. Catalyst promotes re-use of existing Perl modules that already handle common web application concerns well.
+Catalyst follows the Model-View-Controller (MVC) design pattern, allowing you to easily separate concerns, like content, presentation and flow control, into separate modules. This separation allows you to modify code that handles one concern without affecting code that handles the others. Catalyst promotes 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.
=head3 Setup
- $ catalyst My::App
+ $ perl /path/to/catalyst My::App
$ cd My-App
- $ bin/create controller My::Controller
+ $ perl bin/create controller My::Controller
=head3 Run
- $ bin/server
+ $ perl bin/server
Now visit these locations with your favorite browser or user agent to see Catalyst in action:
$c->req->headers->content_type;
$c->req->base;
-=item * L<Catalyst::Reponse>
+=item * L<Catalyst::Response>
$c->response
$c->res # alias
-The response is like the request but contais just response specific informations.
+The response is like the request but contains just response specific informations.
$c->res->output('Hello World');
$c->res->status(404);
=head3 Actions
-To define a Catalyst action, register it into your applicaton with the C<action> method. C<action> accepts a key-value pair, where the key represents one or more URLs or application states and the value is a code reference, the action to execute in reponse to the URL(s) or application state(s).
+To define a Catalyst action, register it into your application with the C<action> method. C<action> accepts a key-value pair, where the key represents one or more URLs or application states and the value is a code reference, the action to execute in reponse to the URL(s) or application state(s).
Catalyst supports several ways to define Actions:
=item * Literal
- $c->action( 'foo/bar' => sub { } );
+ MyApp->action( 'foo/bar' => sub { } );
Matches only http://localhost:3000/foo/bar.
=item * Regex
- $c->action( '^/foo(\d+)/bar(\d+)$/' => sub { } );
+ MyApp->action( '^/foo(\d+)/bar(\d+)$/' => sub { } );
Matches any URL that matches the pattern in the action key, e.g. http://localhost:3000/foo23/bar42. The pattern must be enclosed with forward slashes, i.e. '/$pattern/'.
=item * Namespace-Prefixed
package MyApp::Controller::My::Controller;
- $c->action( '?foo' => sub { } );
+ MyApp->action( '?foo' => sub { } );
Matches http://localhost:3000/my_controller/foo. The action key must be prefixed with '?'.
=item * Private
- $c->action( '!foo' => sub { } );
+ MyApp->action( '!foo' => sub { } );
Matches no URL, and cannot be executed by requesting a URL that corresponds to the action key. Private actions can be executed only inside a Catalyst application, by calling the C<forward> method:
=item * !?default, !?begin and !?end
Like their equivalents above but used to overload them from Controllers.
-So each Controller can have their own !?default, !?begin and !?end.
+So each Controller can have its own !?default, !?begin and !?end.
=back
=head4 Controllers
-Multiple Controllers are a good way to separate logical domains of your application and distribute tasks to different programmers in a teams.
+Multiple Controllers are a good way to separate logical domains of your application.
package MyApp::C::Login;