CodeIgniter Forums
Ci4 Learn with Myth - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Ci4 Learn with Myth (/showthread.php?tid=79721)



Ci4 Learn with Myth - cuculetea - 07-23-2021

Hello,
This is my first post. I try o learn ci4. I have some big project working on ci3.
Now i have to improve them and also move on ci4.
I have fresh install on centos 8 with composer.
Because i need a complex system admin with roles and many more i decide to use myth. I need to extend Myth because i need to do a phone verification with sms and also mail verification.

I am stuck on how to extend Myth controller with a new method. I don`t want to modify myth\auth\src\controllers\AuthController.php.
I understande i can create app\controllers\AuthController.php but is not working:

PHP Code:
<?php namespace App\Controllers;

use 
Myth\Auth\Controllers\AuthController as MyAuth;

class 
AuthController extends MyAuth
{
  public function pregister() {
echo 
"a";
//return $this->_render($this->config->views['pregister'], ['config' => $this->config]);
}

I also modify 
PHP Code:
public $views = [
 
'login'   => 'Myth\Auth\Views\login',
 
'register' => 'Myth\Auth\Views\register',
 
'pregister' => 'Myth\Auth\Views\register',
 
'forgot'   => 'Myth\Auth\Views\forgot',
 
'reset'   => 'Myth\Auth\Views\reset',
 
'emailForgot' => 'Myth\Auth\Views\emails\forgot',
 
'emailActivation' => 'Myth\Auth\Views\emails\activation',
 ]; 
Why is not working? What i am doind wrong?


RE: Ci4 Learn with Myth - InsiteFX - 07-23-2021

Try this
PHP Code:
use Myth\Auth\Controllers\AuthController;

class 
MyAuth extends AuthController 
{
    public function __construct()
    {
        parent::__construct();
    }





RE: Ci4 Learn with Myth - MGatner - 07-24-2021

Calling the parent constructor is unnecessary unless you are providing additional functionality - it will be called automatically. @cuculetea can you elaborate on what’s not working? Your setup looks correct - though will also need to add a route to your app/Config/Routes.php in order to reach your new method.


RE: Ci4 Learn with Myth - ikesela - 07-24-2021

why not just publish it (use cli), it make sense and easier.