4 use base qw[ Catalyst::Base Catalyst::Setup ];
5 use UNIVERSAL::require;
6 use Catalyst::Exception;
12 our $CATALYST_SCRIPT_GEN = 4;
14 __PACKAGE__->mk_classdata($_) for qw/arguments dispatcher engine log/;
16 our $VERSION = '5.24';
21 Catalyst - The Elegant MVC Web Application Framework
25 # use the helper to start a new application
29 # add models, views, controllers
30 script/myapp_create.pl model Something
31 script/myapp_create.pl view Stuff
32 script/myapp_create.pl controller Yada
35 script/myapp_server.pl
37 # command line interface
38 script/myapp_test.pl /yada
43 use Catalyst qw/My::Module My::OtherModule/;
45 use Catalyst '-Debug';
47 use Catalyst qw/-Debug -Engine=CGI/;
49 sub default : Private { $_[1]->res->output('Hello') } );
51 sub index : Path('/index.html') {
52 my ( $self, $c ) = @_;
53 $c->res->output('Hello');
57 sub product : Regex('^product[_]*(\d*).html$') {
58 my ( $self, $c ) = @_;
59 $c->stash->{template} = 'product.tt';
60 $c->stash->{product} = $c->req->snippets->[0];
63 See also L<Catalyst::Manual::Intro>
67 The key concept of Catalyst is DRY (Don't Repeat Yourself).
69 See L<Catalyst::Manual> for more documentation.
71 Catalyst plugins can be loaded by naming them as arguments to the "use Catalyst" statement.
72 Omit the C<Catalyst::Plugin::> prefix from the plugin name,
73 so C<Catalyst::Plugin::My::Module> becomes C<My::Module>.
75 use Catalyst 'My::Module';
77 Special flags like -Debug and -Engine can also be specifed as arguments when
80 use Catalyst qw/-Debug My::Module/;
82 The position of plugins and flags in the chain is important, because they are
83 loaded in exactly the order that they appear.
85 The following flags are supported:
91 enables debug output, i.e.:
93 use Catalyst '-Debug';
95 this is equivalent to:
102 Force Catalyst to use a specific engine.
103 Omit the C<Catalyst::Engine::> prefix of the engine name, i.e.:
105 use Catalyst '-Engine=CGI';
115 Overload to enable debug messages.
123 Returns a hashref containing your applications settings.
128 my ( $class, @arguments ) = @_;
130 my $caller = caller(0);
132 # Prepare inheritance
133 unless ( $caller->isa($class) ) {
136 push @{"$caller\::ISA"}, $class;
138 *{"$caller\::import"} = sub { 1 };
141 $caller->arguments( [ @arguments ] );
147 Contains the engine class.
151 Contains the logging object. Unless it is already set Catalyst sets this up with a
152 C<Catalyst::Log> object. To use your own log class:
154 $c->log( MyLogger->new );
155 $c->log->info("now logging with my own logger!");
157 Your log class should implement the methods described in the C<Catalyst::Log>
160 =item $c->plugin( $name, $class, @args )
162 Instant plugins for Catalyst.
163 Classdata accessor/mutator will be created, class loaded and instantiated.
165 MyApp->plugin( 'prototype', 'HTML::Prototype' );
167 $c->prototype->define_javascript_functions;
172 my ( $class, $name, $plugin, @args ) = @_;
175 if ( my $error = $UNIVERSAL::require::ERROR ) {
176 Catalyst::Exception->throw(
177 message => qq/Couldn't load instant plugin "$plugin", "$error"/
181 eval { $plugin->import };
182 $class->mk_classdata($name);
184 eval { $obj = $plugin->new(@args) };
187 Catalyst::Exception->throw(
188 message => qq/Couldn't instantiate instant plugin "$plugin", "$@"/
193 $class->log->debug(qq/Initialized instant plugin "$plugin" as "$name"/)
201 mod_perl2 support is considered experimental and may contain bugs.
207 Join #catalyst on irc.perl.org.
211 http://lists.rawmode.org/mailman/listinfo/catalyst
212 http://lists.rawmode.org/mailman/listinfo/catalyst-dev
216 http://catalyst.perl.org
222 =item L<Catalyst::Manual> - The Catalyst Manual
224 =item L<Catalyst::Engine> - Core Engine
226 =item L<Catalyst::Log> - The Log Class.
228 =item L<Catalyst::Request> - The Request Object
230 =item L<Catalyst::Response> - The Response Object
232 =item L<Catalyst::Test> - The test suite.
238 Sebastian Riedel, C<sri@oook.de>
242 Andy Grundman, Andrew Ford, Andrew Ruthven, Autrijus Tang, Christian Hansen,
243 Christopher Hicks, Dan Sully, Danijel Milicevic, David Naughton,
244 Gary Ashton Jones, Geoff Richards, Jesse Sheidlower, Jody Belka,
245 Johan Lindstrom, Juan Camacho, Leon Brocard, Marcus Ramberg,
246 Tatsuhiko Miyagawa and all the others who've helped.
250 This library is free software . You can redistribute it and/or modify it under
251 the same terms as perl itself.