Free Sample
+ Collection

Web Application Development with Yii and PHP

Jeffrey Winesett

For PHP programmers with a yearning to add modernity and sophistication to their web applications, this book will be a revelation. A step-by-step tutorial to Yii, it talks you through the development of a complete real-world application.
RRP $26.99
RRP $44.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849518727
Paperback332 pages

About This Book

  • A step-by-step guide to creating a modern Web application using PHP, MySQL, and Yii
  • Build a real-world, user-based, database-driven project task management application using the Yii development framework
  • Start with a general idea, and finish with deploying to production, learning everything about Yii inbetween, from "A"ctive record to "Z"ii component library

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 read this book.

Table of Contents

Chapter 1: Meet Yii
MVC architecture
Stitching these together: Yii request routing
Object-relational mapping and Active Record
The view and controller
Chapter 2: Getting Started
Installing Yii
Creating a new application
"Hello, World!"
Adding dynamic content
Linking pages together
Chapter 3: The TrackStar Application
Introducing TrackStar
Creating user stories
Navigation and page flow
Data relationships
Creating the new application
Connecting to the database
Testing the database connection
Chapter 4: Project CRUD
Feature planning
Creating the project table
Creating the AR model class
Enabling CRUD operations for projects
Chapter 5: Managing Issues
Feature planning
Designing the schema
Building objects and their relationships
Creating active record model classes
Creating the issue CRUD operations
Using the issue CRUD operations
Fixing the owner and requester fields
The rest of the CRUD
Final tweaks
Chapter 6: User Management and Authentication
Feature planning
Authenticating users using the database
Chapter 7: User Access Control
Feature planning
Access control filter
Role based access control
Checking authorization level
Chapter 8: Adding User Comments
Feature planning
Creating the model
Creating the comment CRUD
Altering the scaffolding to meet our requirements
Creating a recent comments widget
Chapter 9: Adding an RSS Web Feed
Feature planning
A little background–content syndication, RSS, and Zend Framework
Installing Zend Framework
Using Zend_Feed
Creating user-friendly URLs
Adding the feed links
Chapter 10: Making It Look Good
Feature planning
Designing with layouts
Deconstructing the main.php layout file
Nesting the layouts
Creating themes
Translating the site to other languages
Chapter 11: Using Yii Modules
Feature planning
Working with modules
Restricting admin access
Adding a system-wide message
Chapter 12: Production Readiness
Feature planning
Handling errors
General performance tuning tips

What You Will Learn

  • Auto-generate skeleton web applications as well as CRUD scaffolding for the domain object model using the built-in command-line interface
  • Use Yii database migrations to version and manage your database changes
  • Create user-based applications with Yii's authentication model
  • Enhance your user-based application to control a user's access to feature functionality
  • Write an administrative console application to extend the features provided by Yii's powerful command-line tools
  • Integrate other frameworks and libraries into a Yii application to further extend its feature set
  • Spend less time managing application configuration by taking advantage of Yii's sensible defaults and conventions.
  • Learn how easy it is to implement a multi-user application by utilizing Yii's authentication and role-based authorization models
  • Update your code to properly manage the user's last login time and store it in the database

In Detail

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.


Read More