=head1 NAME
-Catalyst::Manual::Tutorial::CatalystBasics - Catalyst Tutorial - Part 2: Catalyst Application Development Basics
+Catalyst::Manual::Tutorial::CatalystBasics - Catalyst Tutorial - Chapter 2: Catalyst Application Development Basics
=head1 OVERVIEW
-This is B<Part 2 of 10> for the Catalyst tutorial.
+This is B<Chapter 2 of 10> for the Catalyst tutorial.
L<Tutorial Overview|Catalyst::Manual::Tutorial>
=head1 DESCRIPTION
-In this part of the tutorial, we will create a very basic Catalyst web
-application, demonstrating a number of powerful capabilities, such as:
+In this chapter of the tutorial, we will create a very basic Catalyst
+web application, demonstrating a number of powerful capabilities, such
+as:
=over 4
scripts unless you install both L<Catalyst::Runtime|Catalyst::Runtime>
and L<Catalyst::Devel|Catalyst::Devel>.
-In this first part of the tutorial, use the Catalyst
-C<catalyst.pl> script to initialize the framework for an
-application called C<Hello>:
+In this first chapter of the tutorial, use the Catalyst C<catalyst.pl>
+script to initialize the framework for an application called C<Hello>:
$ catalyst.pl Hello
created "Hello"
directory.
Run the following command to start up the built-in development web
-server:
+server (make sure you didn't forget the "C<cd Hello>" from the
+previous step):
$ script/hello_server.pl
[debug] Debug messages enabled
+----------------------+--------------------------------------+--------------+
| /default | Hello::Controller::Root | default |
| /end | Hello::Controller::Root | end |
+ | /index | Hello::Controller::Root | index |
'----------------------+--------------------------------------+--------------'
[debug] Loaded Path actions:
| / | /default |
| / | /index |
'-------------------------------------+--------------------------------------'
-
- [info] Hello powered by Catalyst 5.7014
- You can connect to your server at http://localhost:3000
+
+ [info] Hello powered by Catalyst 5.71000
+ You can connect to your server at http://debian:3000
Point your web browser to L<http://localhost:3000> (substituting a
different hostname or IP address as appropriate) and you should be
-greeted by the Catalyst welcome screen. Information similar to the
-following should be appended to the logging output of the development
-server:
-
- [info] *** Request 1 (1.000/s) [10301] [Sun Nov 23 10:11:36 2008] ***
- [debug] "GET" request for "/" from "127.0.0.1"
- [info] Request took 0.017964s (55.667/s)
+greeted by the Catalyst welcome screen (if you get some other welcome
+screen or an "Index" screen, you probably forgot to specify port 3000
+in your URL). Information similar to the following should be appended
+to the logging output of the development server:
+
+ [info] *** Request 1 (0.005/s) [20712] [Sun Mar 8 15:49:09 2009] ***
+ [debug] "GET" request for "/" from "1.1.1.98"
+ [info] Request took 0.007342s (136.203/s)
.----------------------------------------------------------------+-----------.
| Action | Time |
+----------------------------------------------------------------+-----------+
- | /default | 0.000540s |
- | /end | 0.001246s |
+ | /index | 0.000491s |
+ | /end | 0.000595s |
'----------------------------------------------------------------+-----------'
Press Ctrl-C to break out of the development server.
$c->response->body("Hello, World!");
}
+B<TIP>: See Appendix 1 for tips on removing the leading spaces when
+cutting and pasting example code from POD-based documents.
+
Here you're sending your own string to the webpage.
Save the file, start the server (stop and restart it if it's still
excellent documentation at L<http://template-toolkit.org/>,
but since this is not a TT tutorial, we'll stick to only basic TT
usage here (and explore some of the more common TT features in later
-parts of the tutorial).
+chapters of the tutorial).
Create a C<root/hello.tt> template file (put it in the C<root> under
the C<Hello> directory that is the base of your application). Here is