2 Catalyst - The Elegant MVC Web Application Framework
5 # use the helper to start a new application
9 # add models, views, controllers
10 script/myapp_create.pl model Something
11 script/myapp_create.pl view Stuff
12 script/myapp_create.pl controller Yada
15 script/myapp_server.pl
17 # command line interface
18 script/myapp_test.pl /yada
22 use Catalyst qw/My::Module My::OtherModule/;
24 use Catalyst '-Debug';
26 use Catalyst qw/-Debug -Engine=CGI/;
28 sub default : Private { $_[1]->res->output('Hello') } );
30 sub index : Path('/index.html') {
31 my ( $self, $c ) = @_;
32 $c->res->output('Hello');
36 sub product : Regex('^product[_]*(\d*).html$') {
37 my ( $self, $c ) = @_;
38 $c->stash->{template} = 'product.tt';
39 $c->stash->{product} = $c->req->snippets->[0];
42 See also Catalyst::Manual::Intro
45 The key concept of Catalyst is DRY (Don't Repeat Yourself).
47 See Catalyst::Manual for more documentation.
49 Catalyst plugins can be loaded by naming them as arguments to the "use
50 Catalyst" statement. Omit the "Catalyst::Plugin::" prefix from the
51 plugin name, so "Catalyst::Plugin::My::Module" becomes "My::Module".
53 use Catalyst 'My::Module';
55 Special flags like -Debug and -Engine can also be specifed as arguments
56 when Catalyst is loaded:
58 use Catalyst qw/-Debug My::Module/;
60 The position of plugins and flags in the chain is important, because
61 they are loaded in exactly the order that they appear.
63 The following flags are supported:
66 enables debug output, i.e.:
68 use Catalyst '-Debug';
70 this is equivalent to:
76 Force Catalyst to use a specific engine. Omit the
77 "Catalyst::Engine::" prefix of the engine name, i.e.:
79 use Catalyst '-Engine=CGI';
83 Overload to enable debug messages.
86 Returns a hashref containing your applications settings.
89 Contains the engine class.
92 Contains the logging object. Unless it is already set Catalyst sets
93 this up with a "Catalyst::Log" object. To use your own log class:
95 $c->log( MyLogger->new );
96 $c->log->info("now logging with my own logger!");
98 Your log class should implement the methods described in the
99 "Catalyst::Log" man page.
101 $c->plugin( $name, $class, @args )
102 Instant plugins for Catalyst. Classdata accessor/mutator will be
103 created, class loaded and instantiated.
105 MyApp->plugin( 'prototype', 'HTML::Prototype' );
107 $c->prototype->define_javascript_functions;
110 By default Catalyst is not case sensitive, so "MyApp::C::FOO::Bar"
113 But you can activate case sensitivity with a config parameter.
115 MyApp->config->{case_sensitive} = 1;
118 mod_perl2 support is considered experimental and may contain bugs.
123 Join #catalyst on irc.perl.org.
127 http://lists.rawmode.org/mailman/listinfo/catalyst
128 http://lists.rawmode.org/mailman/listinfo/catalyst-dev
132 http://catalyst.perl.org
135 Catalyst::Manual - The Catalyst Manual
136 Catalyst::Engine - Core Engine
137 Catalyst::Log - The Log Class.
138 Catalyst::Request - The Request Object
139 Catalyst::Response - The Response Object
140 Catalyst::Test - The test suite.
188 Sebastian Riedel, "sri@oook.de"
191 This library is free software . You can redistribute it and/or modify it
192 under the same terms as perl itself.