4 use base 'Class::Data::Inheritable';
5 use UNIVERSAL::require;
8 __PACKAGE__->mk_classdata($_) for qw/_config log/;
10 our $VERSION = '4.24';
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"/)
164 unshift @ISA, $plugin;
170 $engine = "Catalyst::Engine::$ENV{CATALYST_ENGINE}"
171 if $ENV{CATALYST_ENGINE};
173 die qq/Couldn't load engine "$engine", "$@"/ if $@;
175 $caller->log->debug(qq/Loaded engine "$engine"/) if $caller->debug;
182 Join #catalyst on irc.perl.org.
186 http://lists.rawmode.org/mailman/listinfo/catalyst
187 http://lists.rawmode.org/mailman/listinfo/catalyst-dev
191 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
192 L<Catalyst::Response>, L<Catalyst::Engine>
196 Sebastian Riedel, C<sri@oook.de>
200 Andrew Ruthven, Danijel Milicevic, David Naughton, Gary Ashton Jones,
201 Jesse Sheidlower, Johan Lindstrom, Marcus Ramberg and all the others
206 This library is free software . You can redistribute it and/or modify it under
207 the same terms as perl itself.