Book Image

Agile Web Application Development with Yii1.1 and PHP5

Book Image

Agile Web Application Development with Yii1.1 and PHP5

Overview of this book

This book is a step by step tutorial in developing a real-world application using the incremental and iterative approach to software development. You learn about agile software development by leaning on the agile nature of the Yii application development framework. You touch on each aspect of the software development lifecycle by building a project task management application from concept through production deployment.After a brief, general introduction to the Yii framework and outlining the software development approach taken throughout the book, the chapters break down in the same way as software development iterations do in real-world projects. After the 1st iteration, you will have a working and tested application with a valid, tested connection to a database.In the 2nd and 3rd iterations, we flesh out our main database entities and domain object model and become familiar with Yii's object-relational-mapping (ORM) layer, Active Record. We also learn how to lean on Yii's auto-generation tools to automatically build our create/read/update/delete (CRUD) functionality against our newly created model. These iterations also focus on how Yii's form validation and submission model works. By the end of the third iteration you will have a working application that allows you to mange projects and issues (tasks) within those projects.The 4th and 5th iterations are dedicated to user management. We learn about the built-in authentication model within Yii to assist in application login and logout functionality. We then dive into the authorization model, first taking advantage of a Yii's simple access control model, then implementing the more sophisticated role-based access control (RBAC) framework that Yii provides.By the end of the 5th iteration, all of the basics of a task management application are in place. The next several iterations are focused on the nice-to-haves. We add user comment functionality, introducing a reusable content portlet architecture approach in the process. We add in an RSS Web feed and demonstrate how easy it is to integrate other third-party tools within a Yii application. We take advantage of Yii's theming structure to help streamline and design the application, and then introduce Yii's internationalization (I18N) features so the application can be adapted to various languages and regions without engineering changes.Finally, we turn our focus to production deployment. We introduce ways to optimize performance and security to prepare the application for a real-world production environment.
Table of Contents (19 chapters)
Agile Web Application Development with Yii 1.1 and PHP5
Credits
About the Author
About the Reviewers
Preface
Index

Preface

Yii is a high-performance, component-based application development framework written in PHP. It helps ease the complexity of building large-scale applications. It enables maximum reusability in web programming, and can significantly accelerate the development process. It does so by allowing the developer to build on top of already well-written, well-tested, and production-ready code. It prevents you from having to rewrite core functionality that is common across many of today's web-based applications, allowing you to concentrate on the business rules and logic specific to the unique application being built.

This book takes a very pragmatic approach to learning the Yii Framework. Throughout the chapters we introduce the reader to many of the core features of Yii by taking a test-first approach to building a real-world task tracking and issue management application called TrackStar. All of the code is provided. The reader should be able to borrow from all of the examples provided to get up and running quickly, but will also be exposed to deeper discussion and explanation to fully understand what is happening behind the scenes.

What this book cover

Chapter 1Meet Yii introduces Yii at a high level. We learn the importance and utility of using application development frameworks, and the characteristics of Yii that make it incredibly powerful and useful.

Chapter 2Getting Started walks through a simple Hello, World! style application using the Yii Framework.

Chapter 3The TrackStar Application provides an introduction to the task management and issue tracking application, TrackStar, that will be built throughout the remainder of the chapters. It also introduces the Test Driven Development (TDD) approach.

Chapter 4Iteration 1:Creating The Initial TrackStar Application demonstrates the creation of a new database-driven, Yii web application.

Chapter 5Iteration 2: Project CRUD introduces the automated code generation features of Yii, as we work to build out the "C"reate, "R"ead, "U"pdate and "D"elete functionality for the project entity in our TrackStar application.

Chapter 6Iteration 3: Adding Tasks introduces us to relational active record and controller class filters in Yii, as we add in the management issues into TrackStar.

Chapter 7Iteration 4: User Management and Authentication covers the first part of Yii's user authentication and authorization framework, Authentication.

Chapter 8Iteration 5: User Access Control covers the second part of the user authentication and authentication framework, Authorization. Both Yii's simple access control and role-based access control are covered.

Chapter 9Iteration 6: Adding User Comments takes a deeper dive into writing relational Active Record queries in Yii as well as introduce a basic portlet architecture for reusing content across multiple pages.

Chapter 10Iteration 7: Adding an RSS Web Feed demonstrates how easy it is to integrate other third-party frameworks into a Yii application by integrating the Zend Framework's Web Feed library to create simple RSS feed within our application.

Chapter 11Iteration 8: Making It Pretty: Design, Layout, Themes and Iternationalization (i18n) delves deeper into the presentation tier of Yii, introducing layout views, themes as well as internationalization and localization in Yii.

Chapter 12Iteration 9: ModulesAdding Administration introduces the concept of a module in Yii by using one to add administrative functionality to the application.

Chapter 13Iteration 10: Production Readiness covers error handling, logging, caching and, security as we prepare our TrackStar application for production.

What you need for this book

To follow along in building the TrackStar application, you will need PHP 5, a web server capable of servicing PHP 5 pages, and a database server. The code has been tested using the Apache 2 web server and a MySQL 5 database. It is certainly possible to use a different PHP5-compatible web server and /or different database server product. While we have attempted to make the examples work independent of the specific web server or database server, we cannot guarantee 100% accuracy if you are using something different. Slight adjustments may be required.

Who this book is for

If you are a PHP programmer with knowledge of object-oriented programming and want to rapidly develop modern, sophisticated web applications, then this book is for you. No prior knowledge of Yii is required to follow this book

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: "You can type in help to see a list of commands available to you within his shell."

A block of code is set as follows:

<h1>Hello, World!</h1>  
<h3><?php echo $time; ?></h3>
<p><?php echo CHtml::link("Goodbye",array('message/goodbye')); ?></p>

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

<h1>Hello, World!</h1>  
<h3><?php echo $time; ?></h3>
<p><?php echo CHtml::link("Goodbye",array('message/goodbye')); ?></p>

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

%cd /WebRoot/demo/protected/tests
%phpunit unit/MessageTest.php

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: "Clicking on the About link provides a simple example of a static page."

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, 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

Visit http://www.packtpub.com/files/code/9584_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

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 web site 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.