1
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 3 years have passed since last update.

Larvel8.5.*でTraget Class Does Not Existとでたら

Posted at

前提

Laravel8.5.*

事象

Laravelをインストールしてプロジェクトを始めてみたが、以前のLaravelのように
うまくルーティングされない。
エラーとして「Traget Class Does Not Exist」と出る。

解決方法

RouteServiceProvider.phpファイルの$namespaceがコメントアウトされています。
コメントアウトを外すと動きます。

/app/Providers/RouteServiceProvider.php

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

最後に

考えた経緯

・エラーメッセージでググってみたら

 ->namespace($this->namespace)

を付け足すみたいなことを書いてあるのですが、すでに書いてありました。

・動かない理由はつまるところ、$this->namespaceが読み込めてないからだな、と。
・フィールドを読みに行くとコメントアウトされてました。

思ったこと

・ある程度柔軟にディレクトリ構造を変えられる便利さを学べてよかったです。
・とはいえ、必要以上の設計は不要かと思います。必要になったら増やす方向で今後もシステム開発したいなと思った次第です。

1
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
1
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?