I know that I am not the first one with such a problem. I have read all the existing information on Stackoverflow and other sources but it could not solve my problem that I always will get a ReflectionException Class App\Http\Middleware\xxx does not exist. 
<?php
namespace App\Http\Middleware\xxx;
use Closure;
class xxx
{
    public function handle($request, Closure $next)
    {
        return $next($request);
    }
}
No joke, this is really my class. I have renamed it to xxx to avoid typo. 
All my routes will pass the web and admin Middleware:  
Route::middleware(['web', 'admin'])->group(function() {  
And this is my /app/Http/Kernel.php:  
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \App\Http\Middleware\xxx::class,
    ],  
xxx.php and it location is App\Http\Middleware\. I also tried to modify my composer.json:
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories",
        "App/Http/Middleware/xxx.php"
    ],
which caused following warning:
Warning: Ambiguous class resolution, "App\Http\Middleware\xxx\xxx" was found in both "$baseDir . '/app/Http/Middleware/xxx.php" and "/code/App/Http/Middleware/xxx.php", the first will be used.
                First, change namespace to:
namespace App\Http\Middleware;
Then remove "App/Http/Middleware/xxx.php" from composer.json and run composer du
You also, need to remove web middleware from the routes file if you're using 5.2.27 and higher:
Route::middleware(['admin'])->group(function() { 
                        Change your namespace to -
namespace App\Http\Middleware;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With