4 use base qw[ Catalyst::Base Catalyst::Setup ];
5 use UNIVERSAL::require;
6 use Catalyst::Exception;
11 our $CATALYST_SCRIPT_GEN = 4;
13 __PACKAGE__->mk_classdata($_) for qw/arguments dispatcher engine log/;
15 our $VERSION = '5.34';
20 Catalyst - The Elegant MVC Web Application Framework
24 # use the helper to start a new application
28 # add models, views, controllers
29 script/myapp_create.pl model Something
30 script/myapp_create.pl view Stuff
31 script/myapp_create.pl controller Yada
34 script/myapp_server.pl
36 # command line interface
37 script/myapp_test.pl /yada
42 use Catalyst qw/My::Module My::OtherModule/;
44 use Catalyst '-Debug';
46 use Catalyst qw/-Debug -Engine=CGI/;
48 sub default : Private { $_[1]->res->output('Hello') } );
50 sub index : Path('/index.html') {
51 my ( $self, $c ) = @_;
52 $c->res->output('Hello');
56 sub product : Regex('^product[_]*(\d*).html$') {
57 my ( $self, $c ) = @_;
58 $c->stash->{template} = 'product.tt';
59 $c->stash->{product} = $c->req->snippets->[0];
62 See also L<Catalyst::Manual::Intro>
66 The key concept of Catalyst is DRY (Don't Repeat Yourself).
68 See L<Catalyst::Manual> for more documentation.
70 Catalyst plugins can be loaded by naming them as arguments to the "use Catalyst" statement.
71 Omit the C<Catalyst::Plugin::> prefix from the plugin name,
72 so C<Catalyst::Plugin::My::Module> becomes C<My::Module>.
74 use Catalyst 'My::Module';
76 Special flags like -Debug and -Engine can also be specifed as arguments when
79 use Catalyst qw/-Debug My::Module/;
81 The position of plugins and flags in the chain is important, because they are
82 loaded in exactly the order that they appear.
84 The following flags are supported:
90 enables debug output, i.e.:
92 use Catalyst '-Debug';
94 this is equivalent to:
101 Force Catalyst to use a specific engine.
102 Omit the C<Catalyst::Engine::> prefix of the engine name, i.e.:
104 use Catalyst '-Engine=CGI';
114 Overload to enable debug messages.
122 Returns a hashref containing your applications settings.
127 my ( $class, @arguments ) = @_;
129 # We have to limit $class to Catalyst to avoid pushing Catalyst upon every
131 return unless $class eq 'Catalyst';
133 my $caller = caller(0);
135 unless ( $caller->isa('Catalyst') ) {
137 push @{"$caller\::ISA"}, $class;
140 $caller->arguments( [ @arguments ] );
146 Contains the engine class.
150 Contains the logging object. Unless it is already set Catalyst sets this up with a
151 C<Catalyst::Log> object. To use your own log class:
153 $c->log( MyLogger->new );
154 $c->log->info("now logging with my own logger!");
156 Your log class should implement the methods described in the C<Catalyst::Log>
159 =item $c->plugin( $name, $class, @args )
161 Instant plugins for Catalyst.
162 Classdata accessor/mutator will be created, class loaded and instantiated.
164 MyApp->plugin( 'prototype', 'HTML::Prototype' );
166 $c->prototype->define_javascript_functions;
171 my ( $class, $name, $plugin, @args ) = @_;
174 if ( my $error = $UNIVERSAL::require::ERROR ) {
175 Catalyst::Exception->throw(
176 message => qq/Couldn't load instant plugin "$plugin", "$error"/
180 eval { $plugin->import };
181 $class->mk_classdata($name);
183 eval { $obj = $plugin->new(@args) };
186 Catalyst::Exception->throw(
187 message => qq/Couldn't instantiate instant plugin "$plugin", "$@"/
192 $class->log->debug(qq/Initialized instant plugin "$plugin" as "$name"/)
198 =head1 CASE SENSITIVITY
200 By default Catalyst is not case sensitive, so C<MyApp::C::FOO::Bar> becomes
203 But you can activate case sensitivity with a config parameter.
205 MyApp->config->{case_sensitive} = 1;
209 mod_perl2 support is considered experimental and may contain bugs.
215 Join #catalyst on irc.perl.org.
219 http://lists.rawmode.org/mailman/listinfo/catalyst
220 http://lists.rawmode.org/mailman/listinfo/catalyst-dev
224 http://catalyst.perl.org
230 =item L<Catalyst::Manual> - The Catalyst Manual
232 =item L<Catalyst::Engine> - Core Engine
234 =item L<Catalyst::Log> - The Log Class.
236 =item L<Catalyst::Request> - The Request Object
238 =item L<Catalyst::Response> - The Response Object
240 =item L<Catalyst::Test> - The test suite.
292 Sebastian Riedel, C<sri@oook.de>
296 This library is free software . You can redistribute it and/or modify it under
297 the same terms as perl itself.