List middleware of application

Submitted by sanjok1988 - 3 years ago

This method list out all the registered middleware in laravel

#put this code in web.php and hit from url

Route::get('middleware', function() {
    $collection = collect(Route::getRoutes())->map(function($r){
        if(isset($r->action['middleware']))
            return $r->action['middleware'];
    })->flatten();
    return array_unique($collection->toArray());
});