php - 从 5.2 Laravel 升级到 5.3 时出错

标签 php laravel

我遵循了 Laravel.com 上的升级指南。完成之后,我完成了 composer update,我遇到了这个错误。有人知道如何解决这个问题吗?

谢谢你帮助我

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

路由服务提供者.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');
    });
}
}

最佳答案

错误表明在错误的命名空间中搜索了 Route 类。我确定您没有类\App\Providers\Route。您需要在您的提供程序中为 Route 类添加正确的路径:

使用 Illuminate\Support\Facades\Route;

关于php - 从 5.2 Laravel 升级到 5.3 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39239859/

相关文章:

php - 如何在 Laravel 5.5 中进行多次插入?

php - Laravel 有一个条件关系

php - DOMDocument::loadHTML() 期望参数 2 很长,尝试使用 LIBXML_HTML_NOIMPLIED 参数时给出的字符串

php - 在 Laravel 容器中覆盖单例

javascript - VueJS 表单输入绑定(bind)

php - 根据数据透视表返回选中的复选框

php - 为什么这个简单的PHP代码无法将数据添加到我的数据库中?

php - 如何将变量传递给 Laravel Validator Rule

php - 如何清除 Phalcon 2.0 表单元素值

php - Laravel 5 - DB join 仅返回第一个表列集