Skip to content

Instantly share code, notes, and snippets.

@hiqsol
Created June 27, 2018 19:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hiqsol/6c60b233816db0db8c324720e46f75dc to your computer and use it in GitHub Desktop.
Save hiqsol/6c60b233816db0db8c324720e46f75dc to your computer and use it in GitHub Desktop.
Find full class path by class name using composer class map
#!/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";
}
}
@hiqsol
Copy link
Author

hiqsol commented Jun 27, 2018

Generate class map with composer du -o.

Run script php findClass.php ClassName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment