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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:52:34+00:00 2026-06-01T01:52:34+00:00

Is it good to use an autoloader that load root/app/model/test.php when trying to use

  • 0

Is it good to use an autoloader that load root/app/model/test.php when trying to use App\Model\Test? In this way every class should be organized accordingly to its namespace.

Is this a good approach? If not, why? what would you suggest?

Should I define a specific array namespace => path that will assure that we are not loading an unexpected file? this way I would have to set every time something like $map['App\Model\Test'] = 'root/app/model/test'; and this would basically delete all the fun of autoloader. Isn’t it?

  • 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-06-01T01:52:35+00:00Added an answer on June 1, 2026 at 1:52 am
    1. It is a rather “standard” approach used in OOP
    2. Usually autoloaders are faster when they have a classmap ($map) injected into them. This is because they don’t have to run through the include paths to look up the file with the class being instantiated. Give them an absolute file name, and you’ll decouple them from the include path. Providing a $map also allows you to organize your classes in another fashion (not just filesystem-based naming). Apart from this, there are also class map generators that you could run before to actually achieve this and not have to (re)do it by hand each time you rename or move some class. During development, however, it is more convenient to use the standard autoloading logic (no classmaps), because keeping in sync files and the classes declared in them can get quite tedious and have little do with development itself.

    Reducing the number of boilerplate code is not the only purpose of the autoloader:

    • you load only those class declarations that are actually needed in your code; not all or some declarations; only those that are used
    • it ensures your include_once and require_once in respect to classes happen only in autoloading
    • your classes don’t focus on loading files; they focus on their function
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is good practice to use the main method to test a java/.net class?
This is my requirement, I know that certain algorithms makes good use of Cache,
I come from a mainly PHP background and make good use of the Apache
I like to get inspiration from using web applications that make good use of
Is there a pattern that is good to use when saving and loading different
Original Question: i read that for RESTful websites. it is not good to use
Which R packages make good use of S4 classes? I'm looking for packages that
What is a good use case for uncaught_exception?
I generally stay away from regular expressions because I seldom find a good use
Is it good to use such approach for keeping read-only list of string, for

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.