Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 949 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 949 Bytes

Code Climate

PHP-Dynamic-Autoloader

PHP Dynamic Autoloader

The purpose of creating this class is to provide dynamic autoloading for PHP classes with or without namespaces.

Simply, DynamicAutoloader searches for a class inside a bunch of paths and includes the class if exists.

Usage

  • Set paths as an array:
$loader = new DynamicAutoloader([
	__DIR__ . DIRECTORY_SEPARATOR .'Model',
	__DIR__ . DIRECTORY_SEPARATOR .'Entities',
	__DIR__ . DIRECTORY_SEPARATOR .'Classes',
	...
]);
  • Set paths using PATH_SEPARATOR:
set_include_path(
	__DIR__ . DIRECTORY_SEPARATOR . 'Model'. PATH_SEPARATOR,
	__DIR__ . DIRECTORY_SEPARATOR . 'Entities'. PATH_SEPARATOR,
	__DIR__ . DIRECTORY_SEPARATOR . 'Classes',
);
$loader = new DynamicAutoloader(get_include_path());