W3cubDocs

/CakePHP 3.4

Class ClassLoader

ClassLoader

Namespace: Cake\Core
Location: Core/ClassLoader.php

Properties summary

  • $_prefixes protected
    array

    An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

Method Summary

  • _loadMappedFile() protected
    Load the mapped file for a namespace prefix and relative class.
  • _requireFile() protected
    If a file exists, require it from the file system.
  • Adds a base directory for a namespace prefix.
  • loadClass() public
    Loads the class file for a given class name.
  • register() public
    Register loader with SPL autoloader stack.

Method Detail

_loadMappedFile()source protected

_loadMappedFile( string $prefix , string $relativeClass )

Load the mapped file for a namespace prefix and relative class.

Parameters

string $prefix
The namespace prefix.
string $relativeClass
The relative class name.

Returns

mixed

Boolean false if no mapped file can be loaded, or the name of the mapped file that was loaded.


_requireFile()source protected

_requireFile( string $file )

If a file exists, require it from the file system.

Parameters

string $file
The file to require.

Returns

boolean
True if the file exists, false if not.

addNamespace()source public

addNamespace( string $prefix , string $baseDir , boolean $prepend false )

Adds a base directory for a namespace prefix.

Parameters

string $prefix
The namespace prefix.
string $baseDir

A base directory for class files in the namespace.

boolean $prepend optional false

If true, prepend the base directory to the stack instead of appending it; this causes it to be searched first rather than last.

loadClass()source public

loadClass( string $class )

Loads the class file for a given class name.

Parameters

string $class
The fully-qualified class name.

Returns

string|false

The mapped file name on success, or boolean false on failure.


register()source public

register( )

Register loader with SPL autoloader stack.

Properties detail

$_prefixessource

protected array

An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

[]

© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Core.ClassLoader.html