=head2 What is Catalyst?
-Catalyst is an elegant web application framework, extremely flexible yet
-extremely simple. It's similar to Ruby on Rails, Spring (Java), and
-L<Maypole>, upon which it was originally based. Its most important
-design philosphy is to provide easy access to all the tools you need to
-develop web applications, with few restrictions on how you need to use
-these tools. Under Catalyst, it is always possible to do things in a
-different way. However, this does mean that it is always possible to do
-things in a different way. Other web frameworks are simpler to use and
-easy to get up and running, but achieve this by locking the programmer
-into a single set of tools. Catalyst's emphasis on flexibility means
-that you have to think more to use it. We view this as a feature.
+Catalyst is an elegant web application framework, extremely flexible
+yet extremely simple. It's similar to Ruby on Rails, Spring (Java),
+and L<Maypole>, upon which it was originally based. Its most important
+design philosphy is to provide easy access to all the tools you need
+to develop web applications, with few restrictions on how you need to
+use these tools. However, this does mean that it is always possible to
+do things in a different way. Other web frameworks are B<initially>
+simpler to use, but achieve this by locking the programmer into a
+single set of tools. Catalyst's emphasis on flexibility means that you
+have to think more to use it. We view this as a feature. For example,
+this leads to Catalyst being more suited to system integration tasks
+than other web frameworks.
=head3 MVC
check out the original book on the subject, I<Design Patterns>, by
Gamma, Helm, Johnson, and Vlissides, also known as the Gang of Four
(GoF). Many, many web application frameworks are based on MVC, which
-is becoming a popular design method for web applications.
+is becoming a popular design paradigm for the world wide web.
=head3 Flexibility
=item * B<Built-in Test Framework>
Catalyst comes with a built-in, lightweight http server and test
-framework, making it easy to test applications from the command line.
+framework, making it easy to test applications from the web browser,
+and the command line.
=item * B<Helper Scripts>
belong in the Model or the Controller, etc. Catalyst's flexibility
means that this decision is entirely up to you, the programmer;
Catalyst doesn't enforce anything. See L<Catalyst::Manual::About> for
-a general discussion of these concerns.
+a general discussion of these issues.
All components must inherit from L<Catalyst::Base>, which provides a
simple class structure and some common class methods like C<config> and
=head4 Models
Models are providers of data. This data could come from anywhere - a
-search engine index, a spreadsheet - but typically a Model represents a
-database table. The data source does not intrinsically have much to do
-with web applications or Catalyst - it could just as easily be used to
-write an offline report generator or a command-line tool.
+search engine index, a spreadsheet, the file system - but typically a
+Model represents a database table. The data source does not
+intrinsically have much to do with web applications or Catalyst - it
+could just as easily be used to write an offline report generator or a
+command-line tool.
To show how to define models, again we'll use an already-existing base
class, this time for L<DBIx::Class>: L<Catalyst::Model::DBIC::Schema>.
% sqlite /tmp/myapp.db < myapp.sql
-Now we can create a DBIC::SchemaLoader component for this database.
+Now we can create a DBIC::Schema model for this database.
- script/myapp_create.pl model DBIC DBIC::SchemaLoader 'dbi:SQLite:/tmp/myapp.db'
+ script/myapp_create.pl model MyModel DBIC::Schema MySchema create=static 'dbi:SQLite:/tmp/myapp.db'
L<DBIx::Class::Schema::Loader> automatically loads table layouts and
-relationships. Use the stash to pass data to your templates.
+relationships, and converts them into a static schema definition C<MySchema>,
+which you can edit later.
+
+Use the stash to pass data to your templates.
We add the following to MyApp/Controller/Root.pm
sub view : Global {
my ( $self, $c, $id ) = @_;
- $c->stash->{item} = $c->model('DBIC::Foo')->find($id);
+ $c->stash->{item} = $c->model('MyModel::Foo')->find($id);
}
1;
$c->stash->{records} = \@records;
}
-But by using a Model that is part of your Catalyst application, you gain
-several things: you don't have to C<use> each component, Catalyst will
-find and load it automatically at compile-time; you can C<forward> to
-the module, which can only be done to Catalyst components; and only
-Catalyst components can be fetched with
+But by using a Model that is part of your Catalyst application, you
+gain several things: you don't have to C<use> each component, Catalyst
+will find and load it automatically at compile-time; you can
+C<forward> to the module, which can only be done to Catalyst
+components. Only Catalyst components can be fetched with
C<$c-E<gt>model('SomeModel')>.
Happily, since many people have existing Model classes that they
...
}
-to handle a C</catalog/*/item/*> path. For extensive information about this
+to handle a C</catalog/*/item/*> path. For further information about this
dispatch type, please see L<Catalyst::DispatchType::Chained>.
=item * B<Private>
and C<MyApp::Controller::Catalog::Order::begin> would override this in
turn.
+=over 4
+
=item * B<auto : Private>
In addition to the normal built-in actions, you have a special action
the I<most> specific class. I<This is the reverse of the order in which
the normal built-ins override each other>.
+=back
+
Here are some examples of the order in which the various built-ins
would be called:
=head1 SEE ALSO
+=over 4
+
=item * L<Catalyst::Manual::About>
=item * L<Catalyst::Manual::Tutorial>
=item * L<Catalyst>
+=back
+
=head1 SUPPORT
IRC: