Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
extending simple auth class
  • I want to add some new methods in simple auth class.Should i extend the simple auth class or i can create new functions in the existing class.How to extend the simple auth class if needed.Need some sugesstion.
  • As a general principle, never modify framework code. It will lead to a merge misery when it becomes time to upgrade. Either extend an existing driver, or write a new driver. See http://fuelphp.com/forums/topics/view/3275 for a similar discussion.
  • hi
    I did as per the documentation and the link u have provided. I am using modules. I got the error file not found.
    I created a module called login. I created a file
    //login/classes/auth/login/simpleauth.php
    namespace Login;
    class Auth_Login_SimpleAuth  extends \Auth\Auth_Login_SimpleAuth{
        //put your code here
        function before(){
            parent::before();
        }
        function test(){
            echo 'test';
        }
        
    }
    
    I added the following in bootstrap file
    Autoloader::add_classes(array(
     // Add classes you want to override here
     // Example: 'View' => APPPATH.'classes/view.php',
        'Auth_Login_SimpleAuth'=>APPPATH.'modules'.DS.'login/classes/auth/login/simpleauth.php'
       
    ));
    
  • You don't need to add anything to a bootstrap, that also is modifying the package. Instead, tell Auth to use your driver (\Login\Auth_Login_SimpleAuth) instead of the default driver. For this to work the Login module most be loaded, either through always_load in the config, or via Fuel::add_module(). If not, the Login namespace is not registered, and the class will not be found.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion