dqqs64238 2016-06-29 22:49
浏览 465
已采纳

调用未定义的方法Route :: name()

im trying to set a name for my route

Route::get('test/show/{id}' , 'TestController@show');

accourding to documentation

Instead of specifying the route name in the route array definition, you may chain the name method onto the end of the route definition:

Route::get('user/profile','UserController@showProfile')->name('profile');

so i wrote

Route::get('test/show/{id}' , 'TestController@show')->name('testShow');

but i get

FatalErrorException in routes.php line 28:
Call to undefined method Illuminate\Routing\Route::name()
in routes.php line 28
at FatalErrorException->__construct() in compiled.php line 1743
at HandleExceptions->fatalExceptionFromError() in compiled.php line 1738
at HandleExceptions->handleShutdown() in compiled.php line 0
in compiled.php line 17158
at RouteServiceProvider->App\Providers\{closure}() in compiled.php line 6819
at call_user_func() in compiled.php line 6819
at Router->group() in compiled.php line 17159
at RouteServiceProvider->map() in compiled.php line 925
at call_user_func_array() in compiled.php line 925
at Container->call() in compiled.php line 4858
at RouteServiceProvider->loadRoutes() in compiled.php line 4840
at RouteServiceProvider->boot() in compiled.php line 17153
at RouteServiceProvider->boot() in compiled.php line 925
at call_user_func_array() in compiled.php line 925
at Container->call() in compiled.php line 1518
at Application->bootProvider() in compiled.php line 1510
at Application->Illuminate\Foundation\{closure}() in compiled.php line 1511
at array_walk() in compiled.php line 1511
at Application->boot() in compiled.php line 1785
at BootProviders->bootstrap() in compiled.php line 1311
at Application->bootstrapWith() in compiled.php line 1928
at Kernel->bootstrap() in compiled.php line 1890
at Kernel->sendRequestThroughRouter() in compiled.php line 1880
at Kernel->handle() in index.php line 53
in index.php line 21
at {main}() in index.php line 0
  • 写回答

3条回答 默认 最新

  • duanjizi9443 2016-06-29 22:57
    关注

    This import is wrong:

    use Illuminate\Routing\Route;

    You actually don't have to import any class as Laravel registers a global alias Route.

    If you want to import the right class, that would be:

    use Illuminate\Support\Facades\Route;

    on top of route.php file

    EDIT: this problem Works fine for me... Are you sure you have at least Laravel 5.1 version? This feature wasn't available in 5.0

    If not : You need to run

    composer update

    in your terminal to get the latest Laravel 5.1.* version.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码