Doubt about autoload php

1
About autoload I studied about:

Autoload for classes in the same folder

function __autoload($nomeClass) {
require_once ("$nomeClass.php");
  }

Autoload for classes in specific folders

spl_autoload_register(function ($nomeClass) {
    if (file_exists("Classes".DIRECTORY_SEPARATOR.$nomeClass.".php") === true) {
        require_once ("Classes".DIRECTORY_SEPARATOR.$nomeClass.".php");
    }
});

How would I make autoload work not just inside the "classes" folder but it load any call class anywhere in the project, how do I do that?

    
asked by anonymous 03.01.2018 / 14:14

1 answer

1

The ideal is to follow the PHP standards.

PSR-0 Discontinued but worth reading >

In use

03.01.2018 / 14:33