PHP Class that handles all includes / required files In effort to streamline applicable PHP file include or require functions I thought that making a class to handle this might be a good idea.

Originally I had an includes/init.php file that included everything, I wanted to make this more dynamic to the specific page the user was on. For example, some pages require the Google maps script or custom Javascript that other pages don't need.

Here is a quick simplified example that doesn't address the dynamic include declarations yet:

class JIncludes {
    public function getClasses() {
        foreach (glob("includes/classes/*.php") as $filename) {
            require_once($filename);
        }
    }

    public function getCoreTop() {
        require_once('includes/core/head.php');
        require_once('includes/core/header.php');
    }

    public function getCoreBottom() {
        require_once('includes/core/footer.php');
    }
}


Is this even a good idea? Will creating this Class object cause more overhead then the alternative?

I have tested this with the following in my index.php:

$include = new JIncludes();
$include-&gt;getClasses();
$include-&gt;getCoreTop();

$db = new DB('local');
$db-&gt;prepare('String');


The source shows the html from my head.php file fine and my PDO DB class works as well. Am I over-complicating things?
Mixing

You are mixing 2 things:


class loading
"template" loading


You aren't over complicating things - you try to over simplify them.

Class loading

In your solution you are loading all classes if only (for example) 2 of them required to serve the request the loading of the other 52321 class is just a waste of time and resources.

Read about automatic class loading: Autoloading Classes

With this feature in your mind you can create a custom logic to load the necessary classes (name resolution, class location in file system etc.).

Template

The other thing what you want is loading your templates into the rendering process. This is hard to do it right, all depends on your "framework" solutions for example naming conventions, is your app frame an MVC based stuff etc.