samedi 26 septembre 2015

Using \App::before() in RouteServiceProvider

Migrating from Laravel 4.2 to Laravel 5.0. I moved \App::before(function($request) from my L4.2 filters.php to the L5.0's RouteServiceProvider.php’s boot() method, but I’m getting a

FatalErrorException in Facade.php line 210: Call to undefined method Illuminate\Foundation\Application::before()

error thrown from it. What am I doing wrong?

I haven’t found anything that says this shouldn’t work; an SO question/answer says that it worked for another guy, so I'm not sure where my code is different. I've tried include use Illuminate\Support\Facades\App; and just \App::before, to no avail.

<?php namespace App\Providers;

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\App;

class RouteServiceProvider extends ServiceProvider {

    protected $namespace = 'App\Http\Controllers';

    public function boot(Router $router)
    {

        App::before(function($request)
        {
            //My before code
        });
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire