jeudi 15 décembre 2016

Laravel Middleware - ReflectionException in Container.php

I'm looking for help because I'm having this error message when I try to load an Middleware.

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

I've checked the Kernel, namespaces,etc. and it seems to be ok. I'll post it anyway because maybe I'm missing something.

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 (placed in /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);
    }
}

Using it

<?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']]);
    }

I've run the commands "composer dump autoload" , "php artisan clear-compiled" and "php artisan optimize" but the error still appears when I try to access to any function included on this Controller.

Someone can help me? Thanks so much.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire