How works the php autoload feature ?


You may have a lot of class that you need to load 1)

It's the case when building an object-oriented applications PHP where there is one source file per class definition.

You may write a long list of require/includes at the beginning of each script (one for each class) but this is cumbersome.

You may register a function with the spl_autoload_register() that will be called when a class is not found.

Class exist Method

class-exists second argument permits to control if the autoload registered method are called or not


With composer autoload ps4, ps0, you can also define where your classes are stored and call its autoload method.

require_once './vendor/autoload.php';

use Module\Class\Path\Hello
echo Hello.get();

Powered by ComboStrap