The ‘include’ of ‘spl_autoload_register’ can’t find the path

The problem was that use needs backslash for the spacename and include needs slash for the path of the file.php where I have the classes. I’m on MacOS X and I read using a Mac generates this kind of problem.

The solution was using a str_replace to convert \ in /.

function monAutoLoad($class) {
    include(str_replace("\\", "/", $class). ".php");


use MesProduits\Produit;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top