Download on GitHub


SubLoader class

A class for simplified inclusion of mass files. For example, pass it a directory, or a list of directories as an array to recursively include all files inside those directories.

Public properties

array $DefinedVariables = array();	// An array of variables to pass to the included files
array $IncludedFiles;			// List of successfully included files after RunIncludes() has ran
array $ErrorFiles;			// List of unsuccessfully included files after RunIncludes() has ran


If you wanted to include all PHP files in the "site/classes" directory, use the below:

1. $SubLoader = new SubLoader($PHPZevelop->CFG->SiteDir);
2. $SubLoader->RunIncludes(array("classes"));
3. extract($SubLoader->DefinedVariables);

Line 1 is intantiating the SubLoader class, the constructor takes the root path of the website.

Line 2 is running the includes, the parameter can be a string or an array of strings that represent the directory names.

Line 3 is extracting the variables that may have been in the files that were included.

© PHPZevelop 2017 - @_Zephni (Craig Dennis)