Laravel Middleware - Container.php中的ReflectionException

时间:2016-12-15 08:09:47

标签: php laravel laravel-5.1 middleware laravel-middleware

我正在寻求帮助,因为我在尝试加载中间件时遇到此错误消息。

ReflectionException in Container.php line 741:
Class roles does not exist

我检查了内核,命名空间等。它似乎没问题。 无论如何,我会发布它,因为我可能会遗漏一些东西。

Kernel.php

<?php

namespace Imuva\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {

    use \Arcanedev\Localization\Traits\LocalizationKernelTrait;

    /**
     * The application's global HTTP middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Imuva\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \Imuva\Http\Middleware\VerifyCsrfToken::class,
    ];

    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Imuva\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \Imuva\Http\Middleware\RedirectIfAuthenticated::class,
        'roles' => \Imuva\Http\Middleware\RolesMiddleware::class,
    ];

}

Stock RolesMiddleware(放在/ app / Http / Middleware中)

<?php
namespace Imuva\Http\Middleware;

use Closure;

class RolesMiddleware
{
    public function __construct() {

    } 
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        return $next($request);
    }
}

使用它

<?php

namespace Imuva\Http\Controllers;

use Illuminate\Http\Request;
use Imuva\Http\Requests;
use Imuva\Http\Middleware; // This is just testing
use Imuva\Http\Controllers\Controller;
use Session;
use Redirect;
use Illuminate\Routing\Route;
use Barryvdh\DomPDF\Facade as PDF2;
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
use Imuva\GoogleCalendar;


class ActividadesController extends Controller {

    public function __construct() {
        $this->middleware('roles');
        $this->beforeFilter('@find', ['only' => ['edit', 'update', 'destroy', 'show', 'cartelH', 'cartelV']]);
    }

我已经运行了命令&#34; composer dump autoload&#34; ,&#34; php artisan clear-compiled&#34;和&#34; php artisan optimize&#34;但是当我尝试访问此Controller上包含的任何功能时,错误仍会出现。

有人可以帮帮我吗?非常感谢。

0 个答案:

没有答案