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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:33:11+00:00 2026-05-20T11:33:11+00:00

This is a two-part question, though both parts are closely related. I had create

  • 0

This is a two-part question, though both parts are closely related.

I had create a page decorator API for our website and put the autoloader for the decorator classes in our site-wide include file. Another developer thought this was a very bad idea because having an autoloader used everywhere is very dangerous and can cause odd errors. For example, serializing an object to the session and if one of your autoloaded classes has the same name and a __wakeup(), it will be run (though I tried this and was not able to reproduce it). Is it true that autoloading is dangerous, and if so, what potential dangers does it have and how can they be avoided? I am not using __autoload(), but an autoload function with spl_autoload_register().

Another argument he had against using autoload is that it would be slower than including the file directly, which is probably quite obvious. I argued that for the decorator to be guaranteed to work on each page you would have to include every decorator class, so his suggestion was to create a factory class that would get the include and create the class you wanted for you. I could go on-and-on, but I have heard many people tout the merits of autoloading and say that it makes any application faster. I do like it a lot but I still want to do what is best and fastest. Any suggestions?

  • 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-20T11:33:11+00:00Added an answer on May 20, 2026 at 11:33 am

    For example, serializing an object to the session and if one of your autoloaded classes has the same name and a __wakeup(), it will be run (though I tried this and was not able to reproduce it).

    That’s true, in a way. If you have two classes in two files with the exact same name, your autoloader won’t be able to guess which one you want, so you just might end up with the wrong class. The easiest fix for this would be to use namespaces, that’s what they are made for.

    Another argument he had against using autoload is that it would be slower than including the file directly, which is probably quite obvious.

    This is true, again, in a way. Autoloading is slower than a direct include, but do mind that it’s much easier to use, and that you never include files that you don’t need to include. That last part might just make it a tie, or perhaps even faster.

    I argued that for the decorator to be guaranteed to work on each page you would have to include every decorator class, so his suggestion was to create a factory class that would get the include and create the class you wanted for you.

    That’s a whole lot of work for something PHP can do natively. Mind you: if you’re using a self-written Factory in PHP to determine which class to load, you are actually building an autoloader, but just not calling it that 😉

    Any suggestions?

    I personally wouldn’t want to include my files manually. It’s been long since I’ve started using the spl_autoload_register functionality, and I don’t regret it for a bit.

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

Sidebar

Related Questions

This is kind of a two part question. But it both relates to the
This is a two part question. A dumb technical query and a broader query
This is a two part question. Is it possible to take advantage of xVal
This is a two-part question: First, I am interested to know what the best
This is a two-part question. I'm using jQuery for a project and wanting to
This is actually a two part question. First,does the HttpContext.Current correspond to the current
This is kinda....a two part question. The first one is much more important than
This is a two-part question: 1. The original .NET print classes (in System.Drawing.Printing) are
As a followup to this two questions and its answers Question 1 and Question
I have this two uls: <ul actualpage=0 id=lastcompanieslist hideable=true upperpage=1> <li page=0 style=display: none;><img

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.