Skip to content

ahmadmayahi/PHP-Dynamic-Autoloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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());

About

PHP Dynamic Autoloader

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages