PHP Класс 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
Автор: OZ ([email protected])
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$classes
$functions
$modules_dir
$namespaces_dirs
$search_log
$warn_about_not_found

Открытые методы

Метод Описание
__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)

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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 )

Описание методов

__construct() публичный Метод

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

autoload() публичный Метод

public autoload ( string $class_name ) : boolean
$class_name string
Результат boolean

define_home_dir_constant() защищенный Метод

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

generate_filepath() защищенный Метод

protected generate_filepath ( $dir, $class_path )

get_modules_dir() публичный Метод

./../')
public get_modules_dir ( ) : string
Результат string

get_namespaces() публичный Метод

public get_namespaces ( )

get_search_log() публичный Метод

public get_search_log ( )

include_class_file() защищенный Метод

protected include_class_file ( $class_name, $file )

log_search_variant() защищенный Метод

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() публичный Метод

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
Результат boolean

register_namespace_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
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() публичный Метод

Set directory of modules ("vendors")
public set_modules_dir ( string $dir ) : void
$dir string
Результат void

set_warn_about_not_found() публичный Метод

public set_warn_about_not_found ( $warn_about_not_found = true )

start() публичный Метод

start autoloader (register in spl_autoload)
public start ( )

Описание свойств

$classes защищенное свойство

protected $classes

$functions защищенное свойство

protected $functions

$modules_dir защищенное свойство

protected $modules_dir

$namespaces_dirs защищенное свойство

protected $namespaces_dirs

$search_log защищенное свойство

protected $search_log

$warn_about_not_found защищенное свойство

protected $warn_about_not_found