samedi 30 juin 2018

Moving routes/web.php file gives class not found error

I'm working with the Laravel 5.6 framework and I want to move the routes file to another directory. I moved it to the ~/config/routes/web.php from the original ~/routes/web.php directory.

I then changed the mapWebRoutes method in my RouteServiceProvider to this:

Route::middleware('web')
     ->namespace($this->namespace)
     ->group(base_path('config/routes/web.php'));

Now when I try to start up laravel I get the error:

In web.php line 14: Class 'Route' not found

I already checked the aliases array in my app.php config file. There it's just the right class:

'Route'        => Illuminate\Support\Facades\Route::class,

When I change my routes directory back to the original ~/routes/web.php directory, every works.

I also tried to import the class into the web.php routes file like this:

use Illuminate\Support\Facades\Route;

Then I received this error when trying to start up laravel.

In Facade.php line 218: A facade root has not been set.

How can I make it so that I can move my routes file to another directory without getting this error?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KxlNOY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire