Book Image

Catalyst

By : Jonathan Rockway
Book Image

Catalyst

By: Jonathan Rockway

Overview of this book

<p>Many web applications are implemented in a way that makes developing them painful 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 />Everything that your web application needs to do is only written once; you connect to the database in one place, have configuration in one place, etc. Then, you just write actions for each URL that your application needs, without worrying about the database connections or HTML to produce. Catalyst will handle the details so you can worry about writing your application.<br /><br />Catalyst is designed to be reliable. There are hundreds of production applications and thousands of users. The code is well-tested, and new releases almost always maintain compatibility with applications written for older versions. You don't have to worry about Catalyst breaking your application and slowing down your development. It just works.<br /><br />Most importantly, Catalyst has a thriving community. You can ask a question on the IRC channel and get a response at almost any time of the day.<br />&nbsp;<br />This book embodies Catalyst's philosophies of Do It Yourself and Don't Repeat Yourself.</p>
Table of Contents (14 chapters)

Preface

Many web applications are implemented in a way that makes developing them painful 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.

Everything that your web application needs to do is only written once; you connect to the database in one place, have configuration in one place, etc. Then, you just write actions for each URL that your application needs, without worrying about the database connections or HTML to produce. Catalyst will handle the details so you can worry about writing your application. Catalyst is designed to be reliable. There are hundreds of production applications and thousands of users. The code is well-tested, and new releases almost always maintain compatibility with applications written for older versions. You don't have to worry about Catalyst breaking your application and slowing down your development. It just works. Most importantly, Catalyst has a thriving community. You can ask a question on the IRC channel and get a response at almost any time of the day.

This book helps you understand the Catalyst framework, its MVC architecture and also provides detailed walkthroughs to create your web applications. Using this book you can build, test and deploy a site with Catalyst and also learn how to extend Catalyst through plug-ins.

What This Book Covers

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

In Chapter 2, we will 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.

In Chapter 3 we build our first real application the address book. We learn to design and understand the "CRUD" interface to the database of our site and write some Catalyst actions.

In Chapter 4, we add common features to our address book application. We learn how to add sessions to our application programmed search logic and identify users and use their identity to control access to the application. Later, we explore authentication and authorization by implementing page-level and record-level access control.

We build a new application called ChatStat in Chapter 5. Here we explore the features of DBIC for easy handling of data and use Catalyst to get the data from DBIC onto the web.

In Chapter 6 we look at 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.

In Chapter 7, we will develop 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 covers an important part of any project, i.e., 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.

In Chapter 9, we learn to package our application and make it available as a PAR file, ready to run on a real web server.

What You Need for This Book

Throughout this book, we will assume that you have the following packages installed and available:

  • Perl version 5.8.1 or higher

  • A working web server

  • SQLite

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.

There are three styles for code. Code words in text are shown as follows: "The best place for questions is the #catalyst IRC channel."

A block of code will be set as follows:

sub end : Private {
my ($self, $c) = @_;
$c->forward('View::TT');
}

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

$ cpan -i DBD::SQLite DBIx::Class Catalyst::Model::DBIC::Schema

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "The MyApp directory structure shows the directories lib, root, script, and t."

Note

Important notes appear in a box like this.

Note

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 drop an email to , making sure to mention the book title in 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, 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.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/files/code/0956_Code.zip, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.

The downloadable files contain instructions on how to use them.

Errata

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

Questions

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