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 6574975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:19:49+00:00 2026-05-25T15:19:49+00:00

I want to extend some built-in framework classes, but I there are some points

  • 0

I want to extend some built-in framework classes, but I there are some points I ‘m not clear about:

  1. I assume I should put my classes under my components folder, is this the right place?
  2. Should I name the classes like Subfolder_ClassName and the files like ClassName.php?
  3. How do I inherit? The default include paths does not include the framework itself. I assume there is a built in way to do it without me changing the include path/start playing with the autoload function or Simply hard code an include in my code.

Right?

  • 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-25T15:19:50+00:00Added an answer on May 25, 2026 at 3:19 pm

    Placement of source files

    Putting them under /protected/components is a natural choice. If you later develop more generic classes that can be reused across projects, you can think about putting those into a separate directory.

    Naming and directory structure

    This will depend on the scale of your app. If you don’t have lots of components (say under 20) then IMHO you don’t need any directory structure, the components directory is good for all of them. Another practical approach is to put your business components into one directory and your HTML components into another (e.g. widgets).

    Including parent classes

    Your configuration file should have a section like this:

    // autoloading model and component classes
    'import'=>array(
        'application.models.activerecord.*',
        'application.models.forms.*',
        'application.components.*',
        'application.classes.*',
        // etc
    ),
    

    This section actually results in CModule::setImport being called on your application instance to register classes that can be autoloaded. If you want to extend these classes then you don’t need to do anything.

    If some of your components depend on Yii classes that don’t get imported as above, you will need to explicitly import them using Yiibase::import before declaring your class. For example:

    Yii::import('zii.widgets.jui.CJuiSlider');
    
    class MySlider extends CJuiSlider {
        // class contents here
    }
    

    Registering aliases for paths

    If you want to create your own aliases for import paths (e.g. to have a path myapp.components you can reference when importing classes), you can do this using Yiibase::setPathOfAlias. A good place for this is the very top of your configuration file:

    <?php
    Yii::setPathOfAlias('myapp.components','components/my/');
    
    // This is the main Web application configuration. Any writable
    // CWebApplication properties can be configured here.
    return array(
        // your whole app configuration is here, and you can now do this:
       'import'=>array(
           // ...other imports...
           'myapp.components.*',
           // ...other imports...
       ),
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extend a WPF application with database functionality. Which database engine would
I want to extend the basic ControlCollection in VB.NET so I can just add
I want to extend an existing application I made to make it set mixer
In following code, I want to extend the behaviour of a class by deriving/subclassing
Want to know what the stackoverflow community feels about the various free and non-free
I want to develop a framework(eg automation) which people can use.The idea is i
I'm building some crude CMS-like functionality (to get acquinted with Play Framework). For this
I want to build some lists (a, b, c, d) by extending periodically those
Want my FireFox at work to be in sync with my FireFox at my
I want to loop over the contents of a text file and do a

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.