PHP Class Jamm\Autoload\Autoloader

A fully-qualified namespace and class must have the following structure \\(\)* Each namespace must have a top-level namespace ("Vendor Name"). Each namespace can have as many sub-namespaces as it wishes. Each namespace separator is converted to DIRECTORY_SEPARATOR when loading from the file system. Each "_" character in the CLASS NAME is converted to DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace. The fully-qualified namespace and class is suffixed with ".php" when loading from the file system. Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. Default place of "vendors" folder is __DIR__.'/../../' directory, you can change it: use set_modules_dir() method Classes of all packages (libraries), placed in the "vendors" folder, will be autoloaded automatically (in first use). You can map namespace of package, placed in any folder: use register_namespace_dir() method. You can map any class also: use register_class() method. In case of errors E_USER_WARNING will be triggered Methods of this class doesn't throws exceptions
Author: OZ ([email protected])
Afficher le fichier Open project: jamm/memory

Protected Properties

Свойство Type Description
$classes
$functions
$modules_dir
$namespaces_dirs
$search_log
$warn_about_not_found

Méthodes publiques

Méthode Description
__construct ( boolean $autostart = true )
autoload ( string $class_name ) : boolean
get_modules_dir ( ) : string Return modules dir like "/home/dir/modules" By default will be taken directory of this file without two last folders (__DIR__.'/.
get_namespaces ( )
get_search_log ( )
register_class ( string $class_name, string $path ) : boolean Register class - associate name of the class with path to the file (mapping)
register_namespace_dir ( string $namespace, string $dir ) Associate namespace with directory For example, if namespace '\name\space' will be associated with directory '/home/name/space', class '\name\space\subnamespace\Class_Name.php' will be looked in /home/name/space/subnamespace/Class_Name.php
set_modules_dir ( string $dir ) : void Set directory of modules ("vendors")
set_warn_about_not_found ( $warn_about_not_found = true )
start ( ) start autoloader (register in spl_autoload)

Méthodes protégées

Méthode Description
define_home_dir_constant ( ) Define HOME_DIR - by this constant other modules can check, if autoloader is exists
generate_filepath ( $dir, $class_path )
include_class_file ( $class_name, $file )
log_search_variant ( string $method_title, string $class_name, string $filepath = '' ) Add next variant of filepath from searching method to the log

Private Methods

Méthode Description
find_in_classes ( string $class_name ) : boolean Find classname in registered classes
find_in_namespaces ( string $class ) : boolean | string Find path to the file of class in registered namespaces (root namespace is registered automatically)
lookFileInNamespaceDir ( $class_namespace, $mapped_namespace, $class_name, $mapped_dir )
register_root_namespace ( ) : void Register "vendors" directory as root namespace
warning_class_not_found ( $class_name )

Method Details

__construct() public méthode

public __construct ( boolean $autostart = true )
$autostart boolean - call method start in constructor

autoload() public méthode

public autoload ( string $class_name ) : boolean
$class_name string
Résultat boolean

define_home_dir_constant() protected méthode

Define HOME_DIR - by this constant other modules can check, if autoloader is exists
protected define_home_dir_constant ( )

generate_filepath() protected méthode

protected generate_filepath ( $dir, $class_path )

get_modules_dir() public méthode

./../')
public get_modules_dir ( ) : string
Résultat string

get_namespaces() public méthode

public get_namespaces ( )

get_search_log() public méthode

public get_search_log ( )

include_class_file() protected méthode

protected include_class_file ( $class_name, $file )

log_search_variant() protected méthode

Add next variant of filepath from searching method to the log
protected log_search_variant ( string $method_title, string $class_name, string $filepath = '' )
$method_title string
$class_name string
$filepath string

register_class() public méthode

Register class - associate name of the class with path to the file (mapping)
public register_class ( string $class_name, string $path ) : boolean
$class_name string
$path string
Résultat boolean

register_namespace_dir() public méthode

Associate namespace with directory For example, if namespace '\name\space' will be associated with directory '/home/name/space', class '\name\space\subnamespace\Class_Name.php' will be looked in /home/name/space/subnamespace/Class_Name.php
public register_namespace_dir ( string $namespace, string $dir )
$namespace string name\space\ (last symbol - slash, and no slashes in start)
$dir string

set_modules_dir() public méthode

Set directory of modules ("vendors")
public set_modules_dir ( string $dir ) : void
$dir string
Résultat void

set_warn_about_not_found() public méthode

public set_warn_about_not_found ( $warn_about_not_found = true )

start() public méthode

start autoloader (register in spl_autoload)
public start ( )

Property Details

$classes protected_oe property

protected $classes

$functions protected_oe property

protected $functions

$modules_dir protected_oe property

protected $modules_dir

$namespaces_dirs protected_oe property

protected $namespaces_dirs

$search_log protected_oe property

protected $search_log

$warn_about_not_found protected_oe property

protected $warn_about_not_found