Download the PHP package michaeluno/php-classmap-generator without Composer
On this page you can find all versions of the php package michaeluno/php-classmap-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download michaeluno/php-classmap-generator
More information about michaeluno/php-classmap-generator
Files in michaeluno/php-classmap-generator
Package php-classmap-generator
Short Description A PHP class that generates class maps for autoload.
License MIT
Informations about the package php-classmap-generator
PHP Class Map Generator
A PHP class that generates class maps for autoload.
Installation
Composer
To install the library using Composer, run
Usage
Instantiate the class with options.
This creates a class map file looking like a following.
Before including the map file, define the constant CLASS_MAP_BASE_DIR_VAR
in your PHP script.
or whatever the base directory path should be.
This automatically inserted string CLASS_MAP_BASE_DIR_VAR
can be changed to whatever string you need with the option argument base_dir_var
. For more details, see the 4th parameter section.
Interfaces and traits are also included.
Parameters
The class accepts four parameters.
1. (string) Base Directory Path
The first parameter accepts the base directory path.
This is required because scanned and gathered absolute paths are on the system where the script runs. However, the actual users of your programs do not share the same absolute paths depending on their systems. That's why the base directory path will be replaced with a constant or a variable in the output.
2. (string|array) Scan Directory Paths
The second parameter accepts directory paths to scan. For multiple paths, pass an numerically indexed array holding them.
Examples
3. (string) The output PHP file path.
Set a path that the generated list will be written.
4. Options (optional)
This parameter accepts an array holding options.
output_buffer
: (boolean) whether output buffer should be printed.exclude_classes
: (array) an array holding class names to exclude.base_dir_var
: (string) the variable or constant name that is prefixed before the inclusion path. Default:__DIR__
.output_var_name
: (string) the variable string that the map array is assigned to. Default:$aClassMap
. Ifreturn
is set, the variable will not be set but the file just returns the generated map array.do_in_constructor
: (boolean) whether to perform the action in the constructor. Default:true
.structure
: (string) eitherCLASS
orPATH
. WhenCLASS
is set, the generated array keys consist of class names. WhenPATH
is set, the generated array keys consist of paths. Default:CLASS
.short_array_syntax
: (boolean) whether to usearray()
or[]
for array declaration.true
for[]
. Default:false
.search
: (array) the arguments for the directory search options.allowed_extensions
: (array) allowed file extensions to be listed. e.g.[ 'php', 'inc' ]
exclude_dir_paths
: (array) directory paths to exclude from the list.exclude_dir_names
: (array) directory base names to exclude from the list. e.g.[ 'temp', '_bak', '_del', 'lib', 'vendor', ]
exclude_file_names
: (array) a sub-string of file names to exclude from the list. e.g.[ '.min' ]
exclude_substrings
: (array) sub-strings of paths to exclude from the list. e.g.[ '.min', '_del', 'temp', 'library', 'vendor' ]
is_recursive
: (boolean) whether to scan sub-directories.ignore_note_file_names
: (array) ignore note file names that tell the parser to skip the directory. When one of the files exist in the parsing directory, the directory will be skipped. Default:[ 'ignore-class-map.txt' ]
,
comment_header
: (array, optional) what header comment to insert at the top of the generated filetext
: (string, optional) the header comment to setpath
: (string, optional) the file path to extract the comment fromclass
: (string, optional) the class name to use its doc-block as the header commenttype
: (string, optional) indicates what type of data to collect. Accepted values areDOCBLOCK
,CONSTANT
.Example
Generating a class map in the script directory.
Do not write to a file
Find CSS files
To find JavaScript files, change the 'css'
part to 'js'
in the allowed_extensions
search argument.
Bundled Utility Autoloader
This package includes an autoloader.
Examples
Including an array of class list
Including the class map file that returns an array of class list
License
Licensed under MIT.