X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=1b948ede8fd6625154c860ea1f4483c12f5cab66;hp=3cdaff079bfb4dfbf17867371fea3733193ab7e4;hb=f279297ad42ed1dc1fc4e2289a4a1dc17acf91d7;hpb=792ad33189eba7c10dd2d2222301481256a1959c diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 3cdaff0..1b948ed 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -97,13 +97,23 @@ doesn't require mod_rewrite or class and method names in URLs. With Catalyst you register your actions and address them directly. For example: - sub hello : Global { + sub hello : Local { my ( $self, $context ) = @_; $context->response->body('Hello World!'); } Now http://localhost:3000/hello prints "Hello World!". +Note that actions with the C< :Global > attribute are equivalent to +using a C<:Path('action_name') > attribute, so our action could be +equivalently: + + sub hi : Path('hello') { + my ( $self, $context ) = @_; + $context->response->body('Hello World!'); + } + + =item * B Use L or L. Other @@ -158,11 +168,14 @@ running, using the helper scripts described above. =head3 Install -Installation of Catalyst can be a time-consuming and frustrating -effort, due to its large number of dependencies. The easiest way -to get up and running is to use Matt Trout's C -script, from L, -and then install L. +Installation of Catalyst can be a time-consuming effort, due to its +large number of dependencies. Although most of the frustrations +associated with this are now ironed out and a simple C or C are now usually +straightforward, if you still have problems, you can use use Matt +Trout's C script, from +L, and then +install L. # perl cat-install # perl -MCPAN -e 'install Catalyst::Devel' @@ -174,6 +187,16 @@ and then install L. $ cd MyApp $ script/myapp_create.pl controller Library::Login +=head4 Frank Speiser's Amazon EC2 Catalyst SDK + +There are currently two flavors of publicly available Amazon Machine +Images (AMI) that include all the elements you'd need to begin +developing in a fully functional Catalyst environment within +minutes. See +L for +more details. + + =head3 Run $ script/myapp_server.pl @@ -337,9 +360,9 @@ Now we can create a DBIC::Schema model for this database. script/myapp_create.pl model MyModel DBIC::Schema MySchema create=static 'dbi:SQLite:/tmp/myapp.db' -L automatically loads table layouts and -relationships, and converts them into a static schema definition C, -which you can edit later. +L can automaticall load table layouts and +relationships, and convert them into a static schema definition +C, which you can edit later. Use the stash to pass data to your templates. @@ -550,9 +573,8 @@ configure your application, load plugins, and extend Catalyst. package MyApp; use strict; - use Catalyst qw/-Debug/; # Add other plugins here, e.g. - # for session support - + use parent qw/Catalyst/; + use Catalyst qw/-Debug ConfigLoader Static::Simple/; MyApp->config( name => 'My Application', @@ -696,9 +718,10 @@ this: # Sets the actions in this controller to be registered with no prefix # so they function identically to actions created in MyApp.pm __PACKAGE__->config->{namespace} = ''; - sub default : Private { + sub default : Path { my ( $self, $context ) = @_; - $context->response->body('Catalyst rocks!'); + $context->response->status(404); + $context->response->body('404 not found'); } 1; @@ -797,6 +820,11 @@ Catalyst ("MyApp::Controller" in the above example), replaces "::" with explanation of the pre-defined meaning of Catalyst component class names. +Note that actions with the C< :Local > attribute are equivalent to the +<:Path('action_name') > so sub foo : Local { } is equivalent to - + + sub foo : Path('foo') { } + =item * B Catalyst also provides a method to build and dispatch chains of actions, @@ -867,26 +895,24 @@ call these built-in private actions in your application class: =over 4 -=item * B +=item * B Called when no other action matches. Could be used, for example, for displaying a generic frontpage for the main app, or an error page for -individual controllers. +individual controllers. B: in older Catalyst applications you +will see C which is roughly speaking equivalent. -If C isn't acting how you would expect, look at using a -L C action (with an empty path string). The difference -is that C takes arguments relative from the namespace and -C I takes arguments relative from the root, regardless -of what controller it's in. Indeed, this is now the recommended way of -handling default situations; the C private controller should -be considered deprecated. -=item * B +=item * B -C is much like C except that it takes no arguments -and it is weighted slightly higher in the matching process. It is -useful as a static entry point to a controller, e.g. to have a static -welcome page. Note that it's also weighted higher than Path. +C is much like C except that it takes no arguments and +it is weighted slightly higher in the matching process. It is useful +as a static entry point to a controller, e.g. to have a static welcome +page. Note that it's also weighted higher than Path. Actually the sub +name C can be called anything you want. The sub attributes are +what determines the behaviour of the action. B: in older +Catalyst applications, you will see C used, which is +roughly speaking equivalent. =item * B @@ -901,9 +927,9 @@ Called at the end of a request, after all matching actions are called. =head4 Built-in actions in controllers/autochaining - Package MyApp::Controller::Foo; + package MyApp::Controller::Foo; sub begin : Private { } - sub default : Private { } + sub default : Path { } sub auto : Private { } You can define built-in private actions within your controllers as @@ -936,15 +962,13 @@ would be called: =item for a request for C - MyApp::begin - MyApp::auto + MyApp::Controller::Foo::auto MyApp::Controller::Foo::default # in the absence of MyApp::Controller::Foo::Foo - MyApp::end + MyApp::Controller::Foo::end =item for a request for C MyApp::Controller::Foo::Bar::begin - MyApp::auto MyApp::Controller::Foo::auto MyApp::Controller::Foo::Bar::auto MyApp::Controller::Foo::Bar::default # for MyApp::Controller::Foo::Bar::foo @@ -964,7 +988,6 @@ like this: false MyApp::Controller::Foo::Bar::begin - MyApp::auto MyApp::Controller::Foo::Bar::end =back