-1

I got the Fatal Error: Fatal error: Class 'app\Autoloader' not found in C:\wamp64\www\WE\index.php In other words: Fatal error: exactly/the/good/way/class not found

begin of my script index.php

<?php
use \app\Autoloader;
Autoloader::register();

Begin of my autoloader script:

namespace app;
class Autoloader{...}

Arborescence:

  • Racine local server
    • app
      • [...]
      • Autoloader.php
  • index.php

Why this fatal error ?? The way mentionned in the error php is right... Thaks for help !

1 Answers1

0

The use statement will need to have the class available first. Since you haven't added the autoloader, you'll have to require_once the PHP file containing the autoloader, then use the class to import it into your namespace.

After the autoloader is present, it will have the responsibility of finding and loading the classes as they're use'd.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84