0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Target class [app\Http\Controllers\TestController] does not exist.

Posted at

Target class [app\Http\Controllers\TestController] does not exist.
というエラーになったので備忘録。

errro.png

コード

routes\web.php
Route::get('/test', [\app\Http\Controllers\TestController::class, 'index']);
resources\views\test.blade.php
Hello<?php echo $name ?>さん,
あなたのレベルは、<?php echo $level ?>です。
app\Http\Controllers\TestController.php
<?php

namespace app\Http\Controllers;
use Illuminate\Http\Request;

class TestController extends Controller
{
    public function index() {
        $data['name'] = 'TEST';
        $data['level'] = 11;

        return view('test', $data);
    }
}

対応

\App\Http\ControllersのAppをappにした。

なぜフォルダ名はAppなのに、名前空間はappでないとダメなのか?

composer.jsonにて、このフォルダはこの名前空間名で呼び出す、というルールになっているため、らしい。

com.png

※バージョン
Laravel Framework 9.18.0

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?