X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FTutorial%2FCatalystBasics.pod;fp=lib%2FCatalyst%2FManual%2FTutorial%2FTutorial%2FCatalystBasics.pod;h=cfa143955c853e059d94ef55ef8e30bbdc105ee7;hp=0000000000000000000000000000000000000000;hb=d442cc9fbdf45a28fe02f13552f44e3e2f7ec22e;hpb=4be096acef2b81af64442da618294f69630029a3 diff --git a/lib/Catalyst/Manual/Tutorial/Tutorial/CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/Tutorial/CatalystBasics.pod new file mode 100644 index 0000000..cfa1439 --- /dev/null +++ b/lib/Catalyst/Manual/Tutorial/Tutorial/CatalystBasics.pod @@ -0,0 +1,1242 @@ +=head1 NAME + +Catalyst::Manual::Tutorial::CatalystBasics - Catalyst Tutorial - Part 2: Catalyst Application Development Basics + + +=head1 OVERVIEW + +This is B for the Catalyst tutorial. + +L + +=over 4 + +=item 1 + +L + +=item 2 + +B + +=item 3 + +L + +=item 4 + +L + +=item 5 + +L + +=item 6 + +L + +=item 7 + +L + +=item 8 + +L + +=item 9 + +L + +=back + + +=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: + +=over 4 + +=item * Helper Scripts + +Catalyst helper scripts that can be used to rapidly bootstrap the +skeletal structure of an application. + +=item * MVC + +Model/View/Controller (MVC) provides an architecture that facilitates a +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: + +=over 4 + +=item * Model + +The model usually represents a data store. In most applications, the +model equates to the objects that are created from and saved to your SQL +database. + +=item * View + +The view takes model objects and renders them into something for the end +user to look at. Normally this involves a template-generation tool that +creates HTML for the user's web browser, but it could easily be code +that generates other forms such as PDF documents, e-mails, or Excel +spreadsheets. + +=item * Controller + +As suggested by its name, the controller takes user requests and routes +them to the necessary model and view. + +=back + +=item * ORM + +The use of Object-Relational Mapping (ORM) technology for database +access. Specifically, ORM provides an automated and standardized means +to persist and restore objects to/from a relational database. + +=back + +You can checkout the source code for this example from the catalyst +subversion repository as per the instructions in +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" + ... + created "MyApp/script/myapp_create.pl" + $ cd MyApp + +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: + + $ script/myapp_server.pl + [debug] Debug messages enabled + [debug] Loaded plugins: + .----------------------------------------------------------------------------. + | Catalyst::Plugin::ConfigLoader 0.13 | + | Catalyst::Plugin::Static::Simple 0.14 | + '----------------------------------------------------------------------------' + + [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] Loaded components: + .-----------------------------------------------------------------+----------. + | Class | Type | + +-----------------------------------------------------------------+----------+ + | MyApp::Controller::Root | instance | + '-----------------------------------------------------------------+----------' + + [debug] Loaded Private actions: + .----------------------+--------------------------------------+--------------. + | Private | Class | Method | + +----------------------+--------------------------------------+--------------+ + | /default | MyApp::Controller::Root | default | + | /end | MyApp::Controller::Root | end | + '----------------------+--------------------------------------+--------------' + + [info] MyApp powered by Catalyst 5.7002 + You can connect to your server at http://localhost:3000 + +B: Be sure you run the C