X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FCatalystBasics.pod;h=2d7eb7b310e6465a57cf60c13a50ab84d82cec83;hp=6b978f3cad90395af78899d12a52443f8281bf1a;hb=d04961970a25ec3dc831f89be5cd6e27fdec884a;hpb=7a600bfec5e8ab5199557e8f73160930b804532c diff --git a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod index 6b978f3..2d7eb7b 100644 --- a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod @@ -5,7 +5,7 @@ Catalyst::Manual::Tutorial::CatalystBasics - Catalyst Tutorial - Part 2: Catalys =head1 OVERVIEW -This is B for the Catalyst tutorial. +This is B for the Catalyst tutorial. L @@ -21,30 +21,34 @@ B =item 3 -L +L =item 4 -L +L =item 5 -L +L =item 6 -L +L =item 7 -L +L =item 8 -L +L =item 9 +L + +=item 10 + L =back @@ -52,9 +56,8 @@ L =head1 DESCRIPTION -In this part of the tutorial, we will create a very basic Catalyst web -application. Though simple in many respects, this section will already -demonstrate a number of powerful capabilities such as: +In this part of the tutorial, we will create a very basic Catalyst web +application, demonstrating a number of powerful capabilities, such as: =over 4 @@ -70,7 +73,7 @@ clean "separation of control" between the different portions of your application. Given that many other documents cover this subject in detail, MVC will not be discussed in depth here (for an excellent introduction to MVC and general Catalyst concepts, please see -L. In short: +L. In short: =over 4 @@ -105,1148 +108,315 @@ to persist and restore objects to/from a relational database. You can checkout the source code for this example from the catalyst subversion repository as per the instructions in -L +L + =head1 CREATE A CATALYST PROJECT -Catalyst provides a number of helper scripts that can be used to quickly -flesh out the basic structure of your application. All Catalyst projects -begin with the C helper (see L -for more information on helpers). Also note that as of Catalyst 5.7000, -you will not have the helper scripts unless you install both -L and L. - -In the case of this tutorial, use the Catalyst C script to -initialize the framework for an application called C: - - $ catalyst.pl MyApp - created "MyApp" - created "MyApp/script" - created "MyApp/lib" - created "MyApp/root" +Catalyst provides a number of helper scripts that can be used to +quickly flesh out the basic structure of your application. All +Catalyst projects begin with the C helper (see +L for more information on helpers). +Also note that as of Catalyst 5.7000, you will not have the helper +scripts unless you install both L +and L. + +In this first part of the tutorial, use the Catalyst +C script to initialize the framework for an +application called C: + + $ catalyst.pl Hello + created "Hello" + created "Hello/script" + created "Hello/lib" + created "Hello/root" ... - created "MyApp/script/myapp_create.pl" - $ cd MyApp + created "Hello/script/hello_create.pl" + $ cd Hello The C helper script will display the names of the -directories and files it creates. - -Though it's too early for any significant celebration, we already have a -functioning application. Run the following command to run this -application with the built-in development web server: +directories and files it creates: + + Changes # Record of application changes + lib # Lib directory for Perl modules + Hello # Application code directory + Controller # Directory for Controller modules + Model # Directory for Models + View # Directory for Views + Hello.pm # Base application module + Makefile.PL # Makefile to build application + hello.conf # Application configuration file + README # README file + root # Equiv of htdocs, dir for templates, css, javascript + favicon.ico + static # Directory for static files + images # Directory for image files used in welcome screen + script # Directory for Perl scripts + hello_cgi.pl # To run your app as a cgi (not recommended) + hello_create.pl # To create models, views, controllers + hello_fastcgi.pl # To run app as a fastcgi program + hello_server.pl # The normal development server + hello_test.pl # Test your app from the command line + t # Directory for tests + 01app.t # Test scaffold + 02pod.t + 03podcoverage.t + + +Catalyst will "auto-discover" modules in the Controller, Model, and +View directories. When you use the hello_create.pl script it will +create Perl module scaffolds in those directories, plus test files in +the "t" directory. The default location for templates is in the "root" +directory. The scripts in the script directory will always start with +the lowercased version of your application name. If your app is +MaiTai, then the create script would be "maitai_create.pl". + +Though it's too early for any significant celebration, we already have +a functioning application. We can use the Catalyst supplied script to +start up a development server and view the default Catalyst page in +your browser. All scripts in the script directory should be run from +the base directory of your application, so change to the Hello +directory. + +Run the following command to start up the built-in development web +server: - $ script/myapp_server.pl + $ script/hello_server.pl [debug] Debug messages enabled [debug] Loaded plugins: .----------------------------------------------------------------------------. - | Catalyst::Plugin::ConfigLoader 0.13 | - | Catalyst::Plugin::Static::Simple 0.14 | + | Catalyst::Plugin::ConfigLoader 0.17 | + | Catalyst::Plugin::Static::Simple 0.20 | '----------------------------------------------------------------------------' [debug] Loaded dispatcher "Catalyst::Dispatcher" [debug] Loaded engine "Catalyst::Engine::HTTP" - [debug] Found home "/home/me/MyApp" - [debug] Loaded Config "/home/me/myapp.yml" + [debug] Found home "/home/me/Hello" + [debug] Loaded Config "/home/me/Hello/hello.conf" [debug] Loaded components: .-----------------------------------------------------------------+----------. | Class | Type | +-----------------------------------------------------------------+----------+ - | MyApp::Controller::Root | instance | + | Hello::Controller::Root | instance | '-----------------------------------------------------------------+----------' [debug] Loaded Private actions: .----------------------+--------------------------------------+--------------. | Private | Class | Method | +----------------------+--------------------------------------+--------------+ - | /default | MyApp::Controller::Root | default | - | /end | MyApp::Controller::Root | end | + | /default | Hello::Controller::Root | default | + | /end | Hello::Controller::Root | end | '----------------------+--------------------------------------+--------------' - [info] MyApp powered by Catalyst 5.7002 + [info] Hello powered by Catalyst 5.7011 You can connect to your server at http://localhost:3000 -B: Be sure you run the C