LoginSignup
3
2

More than 3 years have passed since last update.

Laravel8 で BindingResolutionException Target class [TestController] does not existが出力

Posted at

Laravel8でコントローラーを作成しLaravel7で作成していた時と同じ感じで
下記のようにルーティングを記載しroute:listをしたところBindingResolutionExceptionが発生

web.php
<?php

use Illuminate\Support\Facades\Route;

Route::get('test','TestController@index');

ドキュメント読むと下記のように修正すればOKでした

web.php
<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TestController;

//Route::get('test','TestController@index');
Route::get("test", [TestController::class, 'index']);

//Resourceの書き方も変わった?
// Route::resource('test', 'TestController', ['only' => ['index', 'show','update', 'store', 'destroy']]);
Route::resource('test', TestGroupController::class)->only([
    'index', 'show','update', 'store', 'destroy'
]);


原因はRouteServiceProviderからデフォルトnamespaceが削除されたから何ですかね?
詳しい方教えてください。

参考
https://laravel.com/docs/8.x/controllers

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2