2 CatalystX::Declare - EXPERIMENTAL Declarative Syntax for Catalyst
7 use CatalystX::Declare;
9 application MyApp::Web with Static::Simple {
11 $CLASS->config(name => 'My Declarative Web Application');
14 See also: CatalystX::Declare::Keyword::Application, "class" in
18 use CatalystX::Declare;
20 controller MyApp::Web::Controller::Foo
21 with MyApp::Web::ControllerRole::Bar {
23 use MooseX::Types::Moose qw( Str );
26 has welcome_message => (
33 method _build_welcome_message { 'Welcome' }
36 action base under '/' as '';
40 final action welcome {
41 $ctx->response->body( $self->welcome_message );
46 See also: CatalystX::Declare::Keyword::Controller,
47 CatalystX::Declare::Keyword::Action,
48 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
51 use CatalystX::Declare;
53 controller_role MyApp::Web::ControllerRole::Bar {
55 use MyApp::Types qw( Username );
58 around _build_welcome_message { $self->$orig . '!' }
60 after welcome (Object $ctx) {
62 $ctx->response->body(join "\n",
69 final action special_welcome (Username $name) under base {
71 $ctx->response->body('Hugs to ' . $name);
75 See also: CatalystX::Declare::Keyword::Role,
76 CatalystX::Declare::Keyword::Action, "class" in MooseX::Declare
79 use CatalystX::Declare;
81 view MyApp::Web::View::TT
82 extends Catalyst::View::TT {
85 TEMPLATE_EXTENSION => '.html',
89 See also: CatalystX::Declare::Keyword::View,
90 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
93 use CatalystX::Declare;
95 model MyApp::Web::Model::DBIC::Schema
96 extends Catalyst::Model::DBIC::Schema {
99 schema_class => 'MyApp::Schema',
103 See also: CatalystX::Declare::Keyword::Model,
104 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
107 This module is EXPERIMENTAL
109 This module provides a declarative syntax for Catalyst applications. Its
110 main focus is currently on common and repetitious parts of the
111 application, such as the application class itself, controllers, and
115 The used syntax elements are not parsed via source filter mechanism, but
116 through Devel::Declare, which is a much less fragile deal to handle and
117 allows extensions to mix without problems. For example, all keywords
118 added by this module are separete handlers.
121 The documentation about syntax is in the respective parts of the
122 distribution below the "CatalystX::Declare::Keyword::" namespace. Here
123 are the manual pages you will be interested in to familiarize yourself
124 with this module's syntax extensions:
126 CatalystX::Declare::Keyword::Application
127 CatalystX::Declare::Keyword::Action
128 CatalystX::Declare::Keyword::Controller
129 CatalystX::Declare::Keyword::Role
130 CatalystX::Declare::Keyword::View
131 CatalystX::Declare::Keyword::Model
133 Things like models, views, roles for request or response objects, can be
134 built declaratively with MooseX::Declare, which is used to additionally
135 provide keywords for "class", "role", "method" and the available method
136 modifier declarations. This allows for constructs such as:
138 use CatalystX::Declare;
145 controller MyApp::Web::Controller::Baz {
147 final action qux under '/' {
148 $ctx->response->body(Foo->new->bar)
153 For Usage Information
154 These links are intended for the common user of this module.
159 Although you probably already know Catalyst, since you otherwise
160 probably wouldn't be here, I include these links for completeness
164 The powerful modern Perl object orientation implementation that is
165 used as basis for Catalyst. MooseX::Declare, on which
166 CatalystX::Declare is based, provides a declarative syntax for
170 We inherit almost all functionality from MooseX::Declare to allow
171 the declaration of traditional classes, roles, methods, modifiers,
172 etc. Refer to this documentation first for syntax elements that
173 aren't part of CatalystX::Declare.
175 MooseX::Method::Signatures
176 This isn't directly used, but MooseX::Declare utilises this to
177 provide us with method and modifier declarations. For extended
178 information on the usage of methods, especially signatures, refer to
179 this module after looking for an answer in the MooseX::Declare
182 For Developer Information
183 This section contains links relevant to the implementation of this
187 You could call this is the basic machine room that runs the
188 interaction with perl. It provides a way to hook into perl's source
189 code parsing and change small parts on a per-statement basis.
191 MooseX::MethodAttributes
192 We use this module to easily communicate the action attributes to
193 Catalyst. Currently, this is the easiest solution for now but may be
194 subject to change in the future.
197 Robert 'phaylon' Sedlacek, <rs@474.at>
199 With contributions from, and many thanks to:
205 This program is free software; you can redistribute it and/or modify it
206 under the same terms as perl itself.