yii\BaseYii::autoload PHP Méthode

autoload() public static méthode

This method is invoked automatically when PHP sees an unknown class. The method will attempt to include the class file according to the following procedure: 1. Search in [[classMap]]; 2. If the class is namespaced (e.g. yii\base\Component), it will attempt to include the file associated with the corresponding path alias (e.g. @yii/base/Component.php); This autoloader allows loading classes that follow the PSR-4 standard and have its top-level namespace or sub-namespaces defined as path aliases. Example: When aliases @yii and @yii/bootstrap are defined, classes in the yii\bootstrap namespace will be loaded using the @yii/bootstrap alias which points to the directory where bootstrap extension files are installed and all classes from other yii namespaces will be loaded from the yii framework directory. Also the guide section on autoloading.
public static autoload ( string $className )
$className string the fully qualified class name without a leading backslash "\"
    public static function autoload($className)
    {
        if (isset(static::$classMap[$className])) {
            $classFile = static::$classMap[$className];
            if ($classFile[0] === '@') {
                $classFile = static::getAlias($classFile);
            }
        } elseif (strpos($className, '\\') !== false) {
            $classFile = static::getAlias('@' . str_replace('\\', '/', $className) . '.php', false);
            if ($classFile === false || !is_file($classFile)) {
                return;
            }
        } else {
            return;
        }
        include $classFile;
        if (YII_DEBUG && !class_exists($className, false) && !interface_exists($className, false) && !trait_exists($className, false)) {
            throw new UnknownClassException("Unable to find '{$className}' in file: {$classFile}. Namespace missing?");
        }
    }