shigg shigg - 3 months ago 60
PHP Question

Error when upgrading to 5.3 from 5.2 Laravel

I followed the upgrading guide on Laravel.com. After that's done,I had done composer update, and I came across this error.Does anyone know how to fix this issue?

Thanks for helping me out

FatalThrowableError in RouteServiceProvider.php line 73:
Class 'App\Providers\Route' not found


routeserviceprovider.php

<?php
namespace App\Providers;

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

class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';

/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot()
{
//

parent::boot();

Route::bind('tags', function($name)
{
return \App\Tag::where('name', $name)->firstOrFail();
});

Route::bind('exercise_slug', function($slug)
{
return \App\Exercise::where('slug', $slug)->firstOrFail();
});

Route::bind('exerciseplan_slug', function($slug)
{
return \App\ExercisePlan::where('slug', $slug)->firstOrFail();
});
//Route::bind('profile',function($name){
//return \App\User::whereName($name)->firstOrFail();
//});

Route::bind('article_slug', function($name) {
return \App\Article::where('slug', $name)->firstOrFail();
});

Route::bind('training_request_slug', function($slug)
{
return \App\TrainingRequest::where('slug', $slug)->firstOrFail();
});

Route::bind('trainer_profile', function($user_id)
{
return \App\TrainerProfile::where('user_id',$user_id)->firstOrFail();
});

}

/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
Route::group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/routes.php');
});
}
}

Answer

Error shows that Route class is searched in wrong namespace. Im sure that you not have class \App\Providers\Route. You need to add proper path to Route class in yours provider:

use Illuminate\Support\Facades\Route;

Comments