我尝试遍历所有已加载的类,这些类扩展了某个类。
但是is_subclass_of
抛出“找不到类”错误,如果原因是没有自动加载的扩展类-我无法捕获它。
$allClasses = 'vendor/composer/autoload_classmap.php';
$classes=[];
foreach ($allClasses as $name => $file){
try {
if (is_subclass_of($name,'mynamespace\\project\\src\\models\\BaseWintypeModel'))
{
$classes[] = $name;
}
}
catch(\Throwable $e)
{
echo "caught exception";
}
}
例如,错误
PHP Fatal Error – yii\base\ErrorException
Class 'Illuminate\Support\ServiceProvider' not found
1. in /www/fresh/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php
因为
class ServiceProvider extends \Illuminate\Support\ServiceProvider