Skip to content

Instantly share code, notes, and snippets.

@demonking
Forked from hiqsol/findClass.php
Created August 17, 2020 08:24
Show Gist options
  • Select an option

  • Save demonking/5f8f3660d3e8b9e8c2d60f50049ea5fc to your computer and use it in GitHub Desktop.

Select an option

Save demonking/5f8f3660d3e8b9e8c2d60f50049ea5fc 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";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment