Web Application Development with Yii and PHP

Web Application Development with Yii and PHP

Jeffrey Winesett

Language: English

Pages: 332

ISBN: 1849518726

Format: PDF / Kindle (mobi) / ePub

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.


  • 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.

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.

What you will learn from this book

  • 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

China Experiments: From Local Innovations to National Reform

Getting Started with Raspberry Pi

Theories of Development: Concepts and Applications (6th Edition; Pearson New International Edition)

Getting Started with Phalcon














`name` varchar(255) NOT NULL, `description` text NOT NULL, `create_time` DATETIME default NULL, `create_user_id` INTEGER default NULL, `update_time` DATETIME default NULL, `update_user_id` INTEGER default NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB ; Now, before we jump right in and just use our favorite MySQL database editor to create this table, we need to talk about how we can use Yii to manage the changes that will take place in our database schema as we build our TrackStar application. [ 56

update_time, update_user_id', 'safe', 'on'=>'search'), ); } The rules() method returns an array of rules. Each rule is of the following general format: Array('Attribute List', 'Validator', 'on'=>'Scenario List', … additional options); The Attribute List is a string of comma separated class property names to be validated according to the Validator. The Validator specifies what kind of rule should be enforced. The on parameter specifies a list of scenarios in which the rule should be applied.

presaving/postsaving processing. We then focused on understanding the Yii authentication model in order to enhance it to meet our application requirements so that the user credentials are validated against the values stored in the database. Now that we have covered authentication, we can turn our focus to the second part of Yii's auth-and-auth framework, authorization. This is the focus of the next chapter. [ 151 ] User Access Control User-based web applications, like our TrackStar

who are only able to view project-related content and not alter it in any way. To achieve this type of access control based on the role of a user, we turn to the Role Based Access Control feature of Yii, also referred to more simply as RBAC. [ 160 ] Chapter 7 RBAC is an established approach in computer systems security to managing the access permissions of authenticated users. In short, the RBAC approach defines roles within an application. Permissions to perform certain operations are also

further down at our implementation. To achieve this goal we will perform the following: 1. Add a public static method called getUserRoleOptions() to the Project model class that returns a valid list of role options using the auth manager's getRoles() method. We will use this to populate a roles selection drop-down field in the form, so that we can select the user role when adding a new user to a project. 2. Add a new public method called isUserInProject($user) to the Project model class to

Download sample