Book Image

Yii Project Blueprints

By : Charles R. Portwood ll
Book Image

Yii Project Blueprints

By: Charles R. Portwood ll

Overview of this book

Table of Contents (15 chapters)
Yii Project Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the controller to manage users


Next, we'll need to implement the necessary methods to create and modify users within our application. Since our users table doesn't have any concept of roles yet, we'll manage our users from the command line through CConsoleCommand. This method will ensure that only authenticated users (users who have access to our server) can modify the user's information. In a real-world application, this functionality can be moved to a secured UsersController in our application.

Creating users

To start with our user management, create a new console command in protected/commands/UserCommand.php, and add the following:

<?php class UserCommand extends CConsoleCommand {}

The CConsoleCommand class is very similar to our controllers. In that, we can define actions that we want to run as well as any parameters that we want added. The first action we should create is an action to create our users. Since we've already set up our Users model to handle the appropriate password...