before uploading to cpanel i tried my laravel project and all work well. after i uploading it to cpanel all page that don't have middeware work well but the page with middleware return:
ReflectionException (-1)Class App\Http\Middleware\MyMiddleware does not exist
here my middeware at App\Http\Middleware\MyMiddleware.php
namespace App\Http\Middleware;
use Closure;
class MyMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(session()->has('adminId')){
return redirect('/admin/dashboard');
}else{
if($request->path() == 'admin'){
return redirect('/admin/login');
}else{
return $next($request);
}
}
}
}
and here is my App\Http\Kernel.php
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'myAuth' => \App\Http\Middleware\MyMiddleware::class,
];
here is my route at routes/web.php
Route::get('/admin', ['middleware' => 'myAuth', 'uses' => function(){
echo "nothing";}]);
so far i have try
php artisan config:clear
composer update
composer dump-autoload
before uploading to cpanel, but no luck.