(Very Brief) Intro to Catalyst




http://www.catalystframework.org/
What's a Web Framework?

   a software framework for developming
    dynamic websites
   E.g.
       Ruby on Rails (Rub...
How Does It Fit?

     Database
                                 Web Browser
     e.g. MySql

   Select * FROM..          ...
What Is Its Structure?

 Each app has a directory structure that
 separates model, view, and controller modules.

 /lib/Ap...
Model-View-Controller
   Model:
       Stores and retrieves data (e.g. in a database).
   Controller
       Receives/p...
Install Catalyst (Ubuntu)
●




    sudo aptitude install 
    libcatalyst­perl 
    libcatalyst­modules­perl 
    libconf...
Create an Application

 The ”catalyst.pl” script is used to create the
 initial application structure:


 $ catalyst.pl He...
Start the Application




 $ script/hello_server.pl
View the Application


 Navigate to:

      http://localhost:3000
How it Works

   When you access http://localhost:3000/,
    Catalyst calls index() in
    /lib/Hello/Controller/Root.pm:...
Extending the App

   Add http://localhost:3000/hello
   Just add a new subroutine called ”hello” to
    Root.pm:

    s...
What We've Got

   If in a web browser, you query
    http://localhost:3000/foo,
   in lib/Hello/Controller/Root.pm, a s...
What Else Can Catalyst Do?

   Access a database (e.g. MySql)
       Object-Relation Mapping
   Retrieve user-entered d...
Questions?

   http://www.catalystframework.org/
   Catalyst::Manual
Thank You!



          Zachary D. Blair
     http://www.sfu.ca/~zblair
Upcoming SlideShare
Loading in …5
×

Very Brief Intro to Catalyst

1,343 views

Published on

Published in: Technology
  • Be the first to comment

Very Brief Intro to Catalyst

  1. 1. (Very Brief) Intro to Catalyst http://www.catalystframework.org/
  2. 2. What's a Web Framework?  a software framework for developming dynamic websites  E.g.  Ruby on Rails (Ruby)  Django (Python)  Catalyst (Perl)
  3. 3. How Does It Fit? Database Web Browser e.g. MySql Select * FROM.. HTTP Requests Perl application using Catalyst
  4. 4. What Is Its Structure? Each app has a directory structure that separates model, view, and controller modules. /lib/AppName/Model/ /lib/AppName/View/ /lib/AppName/Controller/Root.pm /root/static/ /script/hello_server.pl Makefile.PL
  5. 5. Model-View-Controller  Model:  Stores and retrieves data (e.g. in a database).  Controller  Receives/processes HTTP requests, reading/manipulating data from the Model and forwarding it to the View for presentation to the user.  View  Formats data for presentation to the user (usually by generating HTML, but could also generate PDF, PNG, etc).
  6. 6. Install Catalyst (Ubuntu) ● sudo aptitude install  libcatalyst­perl  libcatalyst­modules­perl  libconfig­general­perl
  7. 7. Create an Application The ”catalyst.pl” script is used to create the initial application structure: $ catalyst.pl Hello $ cd Hello
  8. 8. Start the Application $ script/hello_server.pl
  9. 9. View the Application Navigate to: http://localhost:3000
  10. 10. How it Works  When you access http://localhost:3000/, Catalyst calls index() in /lib/Hello/Controller/Root.pm: sub index :Path :Args(0) {   my ( $self, $c ) = @_;            # Hello World   $c­>response­>body( $c­>welcome_message ); }
  11. 11. Extending the App  Add http://localhost:3000/hello  Just add a new subroutine called ”hello” to Root.pm: sub hello :Local {   my ( $self, $c ) = @_;   $c­>response­>body( ”Hello!!!!” ); }
  12. 12. What We've Got  If in a web browser, you query http://localhost:3000/foo,  in lib/Hello/Controller/Root.pm, a subroutine called ”foo()” is executed, and  foo() generates HTML that is sent back to the web browser.
  13. 13. What Else Can Catalyst Do?  Access a database (e.g. MySql)  Object-Relation Mapping  Retrieve user-entered data from HTML forms  Generate nice HTML using templates  E.g. Using Template::Toolkit  Integrate with the Apache web server  FastCGI protocol
  14. 14. Questions?  http://www.catalystframework.org/  Catalyst::Manual
  15. 15. Thank You! Zachary D. Blair http://www.sfu.ca/~zblair

×