Difference between #3 and #4 of
Extending common classes to allow better customization

Revision #4 has been created by Steve Friedl on Apr 4, 2011, 4:15:33 PM with the memo:

The framework base class is in fact CController, and Controller is the blog demo's helper class. Fixed a previous revision, plus added the note about the blog demo Controller helper class
« previous (#3) next (#5) »

Changes

Title unchanged

Extending common classes to allow better customization

Category unchanged

Tips

Yii version unchanged

Tags unchanged

Content changed

[...]
```php
<?php
// in protected/components/MyController.php

class MyController extends
CController {

}
[...]
Note: the common Yii convention is to remove the leading `C` when creating custom classes, by I believe it's more obvious that these are user-defined classes by using the `My` prefix. But choose the convention you prefer.

Note#2: If you're looking at the Blog demo, the application controllers **already** extend from `protected/components/Controller.php`, which is the blog's helper class of this kind - no need to extend it again.
 
 
Once these class files have been created, edit each of your controllers and models:

```php
// in protected/controllers/PostController.php

class PostController extends MyController {
[...]
36 0
19 followers
Viewed: 41 395 times
Version: 1.1
Category: Tips
Tags:
Written by: Steve Friedl
Last updated by: Steve Friedl
Created on: Dec 17, 2010
Last updated: 13 years ago
Update Article

Revisions

View all history