Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Need help with error when trying to extend SimpleAuth
  • Hoping someone can lend me a hand. I've been trying to piece together info from these forums on how to extend the SimpleAuth driver, as I am wanting to extend SimpleAuth to allow for additional fields to be included when creating/updating a user. Here is what I have done so far (which may or may not be correct!): 1. Made a new file at app/classes/auth/login/myauth.php, which contains the following: <code>
    class Auth_Login_MyAuth extends Auth\Auth_Login_SimpleAuth
    { }
    </code> 2. Copied auth.php and simpleauth.php from 'packages/auth/config/' to 'app/config/'
    3. In app/config/auth.php changed 'driver' => 'SimpleAuth' to 'driver' => array('SimpleAuth', 'MyAuth')
    4. Copied the create_user() method from SimpleAuth to myauth.php (from step 1): <code>
    class Auth_Login_MyAuth extends Auth\Auth_Login_SimpleAuth
    {
    public function create_user(...)
    {
    ...
    }
    }
    </code> Now when I have the standard create_user parameters (copied from SimpleAuth) the page loads fine, but if I add an extra parameter (e.g. $user_name) to be used later, I get the following error: <code>
    Runtime Notice! ErrorException [ Runtime Notice ]: Declaration of Auth_Login_MyAuth::create_user() should be compatible with that of Auth\Auth_Login_SimpleAuth::create_user() APPPATH/classes/auth/login/myauth.php @ line 269: 268: }
    269: }
    270:
    </code>
    Not sure where to go from here!
  • The notice is quite clear. In PHP, you can not overload a class method with one that has a different argument list without getting this notice (if you have enabled E_STRICT error reporting). Instead of extending the driver, maybe it's better to create a new driver, and use that?

Howdy, Stranger!

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

In this Discussion