PHP code example of michaeluno / php-classmap-generator
1. Go to this page and download the library: Download michaeluno/php-classmap-generator library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
michaeluno / php-classmap-generator example snippets
new \PHPClassMapGenerator\PHPClassMapGenerator(
__DIR__, // base dir
__DIR__ . '/_scandir', // scan dir path
__DIR__ . '/class-map.php', // the result output file
);
$aClassMap = array(
"Foo\FooClass" => CLASS_MAP_BASE_DIR_VAR . "/_scandir/FooClass.php",
"Foo\FooClass_Base" => CLASS_MAP_BASE_DIR_VAR . "/_scandir/FooClass_Base.php",
"Joe\JoeInterface" => CLASS_MAP_BASE_DIR_VAR . "/_scandir/interfaces/JoeInterface.php",
"Bar\Bar" => CLASS_MAP_BASE_DIR_VAR . "/_scandir/traits/BarTrait.php",
);
define( 'CLASS_MAP_BASE_DIR_VAR', __DIR__ );
new \PHPClassMapGenerator\PHPClassMapGenerator(
__DIR__,
__DIR__ . '/scandir',
__DIR__ . '/class-map.php',
);
new \PHPClassMapGenerator\PHPClassMapGenerator(
__DIR__,
[ __DIR__ . '/scandir', __DIR__ . '/scandir2' ],
__DIR__ . '/class-map.php',
);
new \PHPClassMapGenerator\PHPClassMapGenerator(
dirname( __DIR__ ),
[ __DIR__ . '/ 'exclude_classes' => [ 'TestClass' ],
'output_var_name' => '$classMap',
'base_dir_var' => '\MyProject\Registry::$dirPath',
'search' => [
'allowed_extensions' => [ 'php' ],
'exclude_dir_paths' => [ __DIR__ . '/
$_oGenerator = new \PHPClassMapGenerator\PHPClassMapGenerator(
__DIR__, // base dir
__DIR__ . '/_scandir', // scan dir name
__DIR__ . '/class-map.php',
[
'do_in_constructor' => false,
]
);
print_r( $_oGenerator->get() );
$_oGenerator = new \PHPClassMapGenerator\PHPClassMapGenerator(
__DIR__, // base dir
__DIR__ . '/_scandir', // scan dir name
__DIR__ . '/class-map.php',
[
'output_var_name' => 'return',
'do_in_constructor' => false,
'structure' => 'PATH',
'search' => [
'allowed_extensions' => [ 'css' ],
'ignore_note_file_names' => [ 'ignore-css-map.txt' ],
'exclude_file_names' => [ '.min.' ],
],
]
);
print_r( $_oGenerator->get() );
bash
composer
$_aClassMap = [
"PHPClassMapGenerator\\PHPClassMapGenerator" => __DIR__ . "/PHPClassMapGenerator.php",
"PHPClassMapGenerator\\Autoload" => __DIR__ . "/autoload.php",
];
PHPClassMapGenerator\Utility\Autoload::set( $_aClassMap );
PHPClassMapGenerator\Utility\Autoload::set(