1Catalyst::Manual::InterUnsaelrs(C3o)ntributed Perl DocumCeanttaaltyisotn::Manual::Internals(3)
2
3
4
6 Catalyst::Manual::Internals - Catalyst Internals
7
9 This document provides a brief overview of the internals of Catalyst.
10 As Catalyst is still developing rapidly, details may become out of
11 date: please treat this as a guide, and look at the source for the last
12 word.
13
14 The coverage is split into initialization and request lifecycle.
15
16 Initialization
17 Catalyst initializes itself in two stages:
18
19 1. When the Catalyst module is imported in the main application
20 module, it stores any options.
21
22 2. When "__PACKAGE__->setup" is called, it evaluates any options
23 stored ("-Debug"), and makes the application inherit from Catalyst
24 (if that hasn't already been done with an explicit "use base
25 'Catalyst';" or "extends 'Catalyst';". Any specified plugins are
26 then loaded, the application module is made to inherit from the
27 plugin classes. It also sets up a default log object and ensures
28 that the application module inherits from "Catalyst" and from the
29 selected specialized Engine module.
30
31 3. Catalyst automatically loads all components it finds in the
32 $class::Controller, $class::C, $class::Model, $class::M,
33 $class::View and $class::V namespaces (using "Module::Pluggable").
34 As each is loaded, if it has a COMPONENT method then this method
35 will be called, and passed that component's configuration. It then
36 returns an instance of the component, which becomes the $self when
37 methods in that component are called later.
38
39 4. Each controller has it's "register_actions" method called. At this
40 point, the subroutine attributes are retrieved from the
41 MooseX::MethodAttributes::Role::Meta::Map, parsed, and used to
42 build instances of Catalyst::Action, which are then registered with
43 the dispatcher.
44
45 Request Lifecycle
46 For each request Catalyst builds a context object, which includes
47 information about the request, and then searches the action table for
48 matching actions.
49
50 The handling of a request can be divided into three stages: preparation
51 of the context, processing of the request, and finalization of the
52 response. These are the steps of a Catalyst request in detail; every
53 step can be overloaded to extend Catalyst.
54
55 handle_request
56 prepare
57 prepare_request
58 prepare_connection
59 prepare_query_parameters
60 prepare_headers
61 prepare_cookies
62 prepare_path
63 prepare_body (unless parse_on_demand)
64 prepare_body_parameters
65 prepare_parameters
66 prepare_uploads
67 prepare_action
68 dispatch
69 finalize
70 finalize_uploads
71 finalize_error (if one happened)
72 finalize_headers
73 finalize_cookies
74 finalize_body
75
76 These steps are normally overloaded from engine classes, and may also
77 be extended by plugins. For more on extending Catalyst, see
78 Catalyst::Manual::ExtendingCatalyst.
79
80 The engine class populates the Catalyst request object with information
81 from the underlying layer (PSGI) during the prepare phase, then push
82 the generated response information down to the underlying layer during
83 the finalize phase.
84
86 Catalyst Contributors, see Catalyst.pm
87
89 This library is free software. You can redistribute it and/or modify it
90 under the same terms as Perl itself.
91
92
93
94perl v5.28.1 2014-12-13 Catalyst::Manual::Internals(3)