只需将我的Laravel应用程序从本地环境迁移到远程服务器上的在线开发环境。迁移之后,我得到一个错误:
ReflectionException thrown with message "Class App\Http\MiddleWare\NotUser does not exist"
我已经删除了vendor
文件夹以及composer.lock
并运行了composer update
。还清除了bootstrap/cache
,并尝试运行php artisan config:clear
。
从存储中清除了所有cache/*
个文件。每当我尝试登录到仪表板时,都会收到以下错误消息:中间件不存在。
app / Http / Middleware / NotUser.php
<?php
namespace App\Http\Middleware;
use Closure;
class NotUser
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
# This middleware prevents anyone who is not an admin from accessing given route or controller
# apply by using it in the constructor, $this->middleware('is.admin');
if ($request->user()->role->name === 'user') {
return back()->with('error', __('Access denied'));
}
return $next($request);
}
}
app / Http / Kernel.php
protected $routeMiddleware = [
...
'not.user' => \App\Http\MiddleWare\NotUser::class
];
routes / web.php
Route::group(['prefix' => 'admin', 'middleware' => ['not.user', 'auth']], function () { ... }
这在本地托管环境下工作正常。我没问题切换到开发环境后,我开始收到此错误,我不知道是什么原因造成的。
答案 0 :(得分:2)
我认为名称空间区分大小写,因此请更改此内容:
recursion()
对此:
#include <stdio.h>
int main() {
int i, j, n = 3, input;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
scanf("%d", &input);
printf("input is : %d\n", input);
}
}
printf("i and j are : %d, %d\n", i, j);
return 0;
}
在protected $routeMiddleware = [
...
'not.user' => \App\Http\MiddleWare\NotUser::class
];
中注意大写字母protected $routeMiddleware = [
...
'not.user' => \App\Http\Middleware\NotUser::class
];
。