Book Image

Catalyst 5.8: the Perl MVC Framework

By : Antano Solar John
Book Image

Catalyst 5.8: the Perl MVC Framework

By: Antano Solar John

Overview of this book

<p>Many web applications are implemented in a way that makes developing them difficult and repetitive. Catalyst is an open source Perl-based Model-View-Controller framework that aims to solve this problem by reorganizing your web application to design and implement it in a natural, maintainable, and testable manner, making web development fun, fast, and rewarding.<br /><br />This book teaches you how to use Catalyst to weave the various components involved in a web application, using methods and tools you personally prefer along with recommendations and details on the most popularly used objects like the DBIX ORM, TT2 Template, and Moose.<br /><br />This book will take you from how the MVC pattern simplifies creating quality applications to how Catalyst allows you to tap this power instantly. It explains advanced design patterns and concludes with the improvements that Moose brings to all this. It also incorporates valuable suggestions and feedback received from the community members and our customers. By the end of the book, you will be able to build clean, scalable, and extendable web applications. This book embodies Catalyst's philosophies of Do It Yourself and Don't Repeat Yourself.</p>
Table of Contents (16 chapters)
Catalyst 5.8
Credits
About the Author
About the Reviewer
Preface
7
Hot Web Topics
Index

Preface

Have you ever created a web application that is almost done but is hard to complete? It is a well known fact that 20 percent of the work takes 80 percent of the time in software development (80-20 rule Frednic Brooks). One of the reasons contributing to this is that it is easy to build web applications, but it's not so easy to build clean, scalable, and extendable web applications. MVC architecture aims at reducing most of the overheads involved in making this transition easy. Catalyst provides a mechanism to implement MVC and more complex design patterns for web application development. This books aims at taking you step- by-step from showing how MVC simplifies creating quality applications to how Catayst allows you to tap this power instantly. The book then takes the journey of good practices and continues to decouple the abstracted layers to explain how to use any object of your choice. The book finally explains advanced design patterns and concludes with the improvements that MOOSE brings in to all this.

What this book covers

Chapter 1, Introduction to Catalyst serves as an introduction to Catalyst and its features. You will also learn how to install it and get it up and running.

Chapter 2, Creating a Catalyst Application shows how to create a Catalyst application skeleton, step through the different files in its directories, and learn how to generate HTML output and connect a SQLite database to Catalyst.

Chapter 3, Building a Real Application covers the building of our first real application—the address book. We learn to design and apply the "CRUD" interface to the database of our site and write some Catalyst actions.

Chapter 4, Expanding the Application explains how to make deployment easy by using the configuration file. We add some of the most common features that web applications need to our address book application. We learn how to add sessions to our application programmed search logic and to identify users and use their identity to control access to the application. We will also learn how to display resultsets that span multiple pages. Finally, we will learn how to utilize our application's model outside of our application. Later, we explore authentication and authorization by implementing page-level and record-level access control.

Chapter 5, Building a More Advanced Application covers how to build a new application called ChatStat. Here we explore the features of DBIC for easy handling of data and use Catalyst to get the data from DBIC onto the Web.

Chapter 6, Building Your Own Model covers the different ways to access the data model. We learn to write a database model and create a filesystem model from scratch, which is integrated with the Catalyst application.

Chapter 7, Hot Web Topics covers the development of a REST API to give the user easy access to our application's data. We also learn to add AJAX interactivity and incorporate RSS feeds in our application.

Chapter 8, Moose shows how Moose can make declarations of methods and properties simpler in our application. We also examine how chained controllers can be easily defined with Catalyst::Declare. We will also discover how Moose allows for Method Signatures and Property constraints along with best practices.

Chapter 9, Deployment teaches us to package our application and make it available as a PAR file, ready to run on a real web server.

Chapter 10, Testing covers an important part of any project, that is, testing. We learn to write programs to test our Catalyst application automatically. We see how to test the individual non-Catalyst components, and then the components inside Catalyst.

What you need for this book

A working machine using Linux, OS X, or Windows on which you have permission to install Perl and Perl packages.

Who this book is for

This book is written for Perl developers who want to start or strengthen their skill and understanding of web application development using MVC principles.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The next step is to create a template in the root/hello directory."

A block of code is set as follows:

sub atom : Local {
  my ($self, $c) = @_;
  $c->stash->{type} = 'Atom';
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

package AddressBook::Controller::Address;
use Moose;
use namespace::autoclean;
BEGIN {extends 'Catalyst::Controller'; }
extends 'Catalyst::Controller::FormBuilder'; 
=head1 NAME

Any command-line input or output is written as follows:

$ apt-get install libcatalyst-perl

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The first link on the index page is Look at all people."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for the book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.