4 use base 'Class::Data::Inheritable';
5 use UNIVERSAL::require;
8 __PACKAGE__->mk_classdata($_) for qw/_config log/;
10 our $VERSION = '4.28';
15 Catalyst - The Elegant MVC Web Application Framework
19 # use the helper to start a new application
23 # add models, views, controllers
24 script/create.pl model Something
25 script/create.pl view Stuff
26 script/create.pl controller Yada
31 # command line interface
37 use Catalyst qw/My::Module My::OtherModule/;
39 use Catalyst '-Debug';
41 use Catalyst qw/-Debug -Engine=CGI/;
43 __PACKAGE__->action( '!default' => sub { $_[1]->res->output('Hello') } );
47 my ( $self, $c ) = @_;
48 $c->res->output('Hello');
54 '/^product[_]*(\d*).html$/' => sub {
55 my ( $self, $c ) = @_;
56 $c->stash->{template} = 'product.tt';
57 $c->stash->{product} = $c->req->snippets->[0];
61 See also L<Catalyst::Manual::Intro>
65 Catalyst is based upon L<Maypole>, which you should consider for smaller
68 The key concept of Catalyst is DRY (Don't Repeat Yourself).
70 See L<Catalyst::Manual> for more documentation.
72 Omit the Catalyst::Plugin:: prefix from plugins.
73 So Catalyst::Plugin::My::Module becomes My::Module.
75 use Catalyst 'My::Module';
77 You can also set special flags like -Debug and -Engine.
79 use Catalyst qw/-Debug My::Module/;
81 The position of plugins and flags in the chain is important,
82 because they are loaded in the same order they appear.
86 use Catalyst '-Debug';
95 Force Catalyst to use a specific engine.
96 Omit the Catalyst::Engine:: prefix.
98 use Catalyst '-Engine=CGI';
104 Overload to enable debug messages.
112 Returns a hashref containing your applications settings.
118 $self->_config( {} ) unless $self->_config;
120 my $config = $_[1] ? {@_} : $_[0];
121 while ( my ( $key, $val ) = each %$config ) {
122 $self->_config->{$key} = $val;
125 return $self->_config;
129 my ( $self, @options ) = @_;
130 my $caller = caller(0);
135 *{"$caller\::handler"} =
136 sub { Catalyst::Engine::handler( $caller, @_ ) };
137 push @{"$caller\::ISA"}, $self;
139 $self->log( Catalyst::Log->new );
143 $ENV{MOD_PERL} ? 'Catalyst::Engine::Apache' : 'Catalyst::Engine::CGI';
148 *{"$self\::debug"} = sub { 1 };
149 $caller->log->debug('Debug messages enabled');
151 elsif (/^-Engine=(.*)$/) { $engine = "Catalyst::Engine::$1" }
152 elsif (/^-.*$/) { $caller->log->error(qq/Unknown flag "$_"/) }
154 my $plugin = "Catalyst::Plugin::$_";
156 # Plugin caller should be our application class
157 eval "package $caller; require $plugin";
159 $caller->log->error(qq/Couldn't load plugin "$plugin", "$@"/);
162 $caller->log->debug(qq/Loaded plugin "$plugin"/)
165 push @{"$caller\::ISA"}, $plugin;
171 $engine = "Catalyst::Engine::$ENV{CATALYST_ENGINE}"
172 if $ENV{CATALYST_ENGINE};
174 die qq/Couldn't load engine "$engine", "$@"/ if $@;
177 push @{"$caller\::ISA"}, $engine;
179 $caller->log->debug(qq/Loaded engine "$engine"/) if $caller->debug;
186 Join #catalyst on irc.perl.org.
190 http://lists.rawmode.org/mailman/listinfo/catalyst
191 http://lists.rawmode.org/mailman/listinfo/catalyst-dev
195 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
196 L<Catalyst::Response>, L<Catalyst::Engine>
200 Sebastian Riedel, C<sri@oook.de>
204 Andrew Ruthven, Christian Hansen, Christopher Hicks, Danijel Milicevic,
205 David Naughton, Gary Ashton Jones, Jesse Sheidlower, Johan Lindstrom,
206 Marcus Ramberg, Tatsuhiko Miyagawa and all the others who've helped.
210 This library is free software . You can redistribute it and/or modify it under
211 the same terms as perl itself.