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

  • Home
  • SEARCH
  • 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 528899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:02:06+00:00 2026-05-13T09:02:06+00:00

One bad thing about using the autoloader is, that it doesn’t know where to

  • 0

One bad thing about using the autoloader is, that it doesn’t know where to look at. My framework already has about 70 classes in about 15 different directories. Because of that, I didn’t go for autoload, but instead struggle around with generating paths. So I have an associative paths array that give me paths from my root file to where I want to go. It works, but it’s really becoming a pain.

First, the user of my framework will very likely have no big idea where a class resides. So creating a FormViewController is already a pain just because you need the path to include it.

For the beginning, I think it would be just fine if PHP had to “search” for the file through multiple directories when it wants to autoload it. So what? Shall PHP do so and save us a lot of pain. But how could I do that most efficently?

Ther’s an array called $paths which I get out of a global context object. The paths could be defined in the array in the most reasonable order: Starting with the most frequently used paths.

I know the PEAR library has a funny naming convention like system_views_specialviews_SpecialView.php which gets converted in the Autoloader to system/views/specialviews/SpecialView.php …but honestly, that’s horrible. Don’t want to mess up my file names like this. For the developer who creates his own classes that would suck just straight away.

Before I re-invent the wheel for this task, maybe someone knows a solution for this?

  • 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-13T09:02:06+00:00Added an answer on May 13, 2026 at 9:02 am

    NB: I’m presuming you’re creating your own custom autoloader via spl_autoload_register, etc.

    If you’re creating an autoloader and the classes you’re looking to include are spread across 15 different directories, I don’t see how you can hope to avoid using some form of class name to directory path mapping, although this obviously doesn’t need to be quite as deep as the example you quote.

    At a simple level, if you keep all of your system libraries in a single area, then a quick case match as such…

    switch(true) {
    
        case substr($className, 0, 6) == 'System': { $libraryPath = 'xxx'; break; }
        ...
    }
    

    …should be reasonably efficient approach, although it obviously depends on how many paths you need to manually check.

    Additionally, I presume you’re checking for the existance of the class prior to attempting to autoload? (i.e.: You’re doing a class_exists($className) to ensure it’s not already been included.) Then again, the requirement for this depends on how often you re-use objects.

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

Sidebar

Ask A Question

Stats

  • Questions 301k
  • Answers 301k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try: echo $_GET['id']; Just in case that "category" is a… May 13, 2026 at 8:07 pm
  • Editorial Team
    Editorial Team added an answer $this-> inside of an object, or self:: in a static… May 13, 2026 at 8:07 pm
  • Editorial Team
    Editorial Team added an answer Try if($myvar == true) and $myvar = true; TRUE and… May 13, 2026 at 8:07 pm

Related Questions

My company is to develop a touchscreen application. We have some prior experience with
Recently I have been reading more and more about people using custom attributes in
This is a generic C++ design question. I'm writing an application that uses a
The Entity Framework context object implements a Dispose() method which Releases the resources used
DataSets were one of the big things in .NET 1.0 and even now when

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.