amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

Custom Controller #175

Open orlandovillarreal opened 8 years ago

orlandovillarreal commented 8 years ago

Hello,

I'm using your yii2 extension on a project I'm doing, but I have a doubt: How can I extend to create my own controller? I have already read the documentation (https://github.com/amnah/yii2-user#how-do-i-extend-this-package) but I had problems in understanding the example you gave. Please keep in mind I'm fairly new to programming, so I would greatly appreciate it if you could be as detailed as possible when giving the explanation.

Thanks a lot and keep up the great work!

amnah commented 8 years ago

The important part in that code is this:

        'controllerMap' => [
            'default' => 'app\controllers\MyDefaultController',
        ],

So you basically need to create a file like app\controllers\MyDefaultController.php and point the module to it. And that file would look like this:

<?php
namespace app\controllers;
use Yii;
class MyDefaultController extends \amnah\yii2\user\controllers\DefaultController
{
}

(Feel free to rename the controller)