Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 726853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:29:58+00:00 2026-05-14T06:29:58+00:00

In Kohana 3, how can I override/extend a module class? E.g. I want to

  • 0

In Kohana 3, how can I override/extend a module class?

E.g. I want to add functionality to the Auth module that is specific to my application. In this case I want to extend the abstract Auth class located in the classes folder of the Auth module.

What naming convention should I use for my Auth class and where in the file system do I place my class file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:29:58+00:00Added an answer on May 14, 2026 at 6:29 am

    To solve this issue it’s important to understand the hierarchical nature of the Kohana 3 framework. When it comes to overriding or extending modules you need to do the following.

    Let’s extend the Auth module. When you look at the Auth module file system structure you notice that in the classes directory there is a file called auth.php. When you open this file you see the following:

    <?php defined('SYSPATH') OR die('No direct access allowed.');
    
    abstract class Auth extends Kohana_Auth { }
    

    Here an abstract class named Auth is defined which is extending the Kohana_Auth class. When you use any references to the Auth class in your application you’re referring to this abstract class. The actual implementation of Auth is actually kept in the Kohana_Auth class which is located in the Kohana folder which part of the module directory structure.

    To extend the Auth module, i.e. add your own functionality, you simply place an auth.php file in the classes folder of your application directory. In your auth.php file you extend your version of the Auth module by extending the Kohana_Auth class. Like so:

    <?php defined('SYSPATH') OR die('No direct access allowed.');
    
    class Auth extends Kohana_Auth {
    
       public function get_user()
       {
          $result = parent::get_user()
    
          // implement your functionality here.
    
          return $result;
       }
    
       public function my_added_functionality()
       {
       }
    
    }
    

    Because of the hierarchical nature of the framework, the abstract class Auth defined as part of the module will never be loaded because the framework loads your Auth class first because it takes precedence. The class you extend, Kohana_Auth, provides all the auth original functionality you can no extent and/or override.

    For more information on the behavior checkout this part of the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Kohana MVC framework. I want to add a module that will
rowanparker https://github.com/rowanparker/kohana-3-paypal I really need this module but I can not use it because
I'm implementing the auth module in Kohana, and I can't seem to figure out
In Kohana 2 you can override the default error page by creating a custom
I have a Kohana 3.0.14 website that i want to put on multiple domains,
I have a question about kohana exceptions. I have a site that I want
In Kohana/CodeIgniter, I can have a URL in this form: http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... And then
So i'm using kohana user module, and i would like to extend my register
How can I update multiple records in Kohana 3.2's ORM? For example this: $menu
Well, its has been almost two hours but I can't get Kohana 3.1 Auth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.