Created
June 27, 2018 19:10
-
-
Save hiqsol/6c60b233816db0db8c324720e46f75dc to your computer and use it in GitHub Desktop.
Find full class path by class name using composer class map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$name = $argv[1]; | |
$pfix = "\\$name"; | |
$len = strlen($pfix); | |
require "vendor/composer/autoload_static.php"; | |
$tmp = get_declared_classes(); | |
$loaderClass = end($tmp); | |
$map = $loaderClass::$classMap; | |
foreach ($map as $class => $path) { | |
if (substr_compare($class, $pfix, -$len, $len) === 0) { | |
echo "$class\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate class map with
composer du -o
.Run script
php findClass.php ClassName