Created
September 16, 2019 03:40
-
-
Save payamomrani/53f75e18592c9a246153eef657824c07 to your computer and use it in GitHub Desktop.
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
$classes = array_filter(get_declared_classes(), function ($class) { | |
$isController = substr($class, -10) == 'Controller'; | |
$isNotPlainController = $isController && substr($class, -11) != '\Controller'; | |
return $isNotPlainController; | |
}); | |
//Optional: to clear controller name from its namespace | |
$controllers=array_map(function ($controller){ | |
return last(explode('\\',$controller)); | |
},$classes); | |
//Optional: to reset keys of array to start from 0,1,2,...etc | |
$controllers = array_values($controllers); | |
//For Admin Controllers | |
$admin_controllers = array_filter($controllers, function ($controller) { | |
return strpos($controller, 'App\Http\Controllers\Admin') !== false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment