Skip to content

Instantly share code, notes, and snippets.

@payamomrani
Created September 16, 2019 03:40
Show Gist options
  • Save payamomrani/53f75e18592c9a246153eef657824c07 to your computer and use it in GitHub Desktop.
Save payamomrani/53f75e18592c9a246153eef657824c07 to your computer and use it in GitHub Desktop.
$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