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

xamppとLaravelで環境構築したらhello worldがうまく画面に表示できなかった件

Last updated at Posted at 2021-10-05

バージョン
xampp 3.3.0
laravel 8.62.0

まず下記を参考に環境構築をする

するとhello worldが表示されず下記エラーになる

lluminate\Contracts\Container\BindingResolutionException
Target class [TestController] does not exist.

なぜか調べるとなんだかLaravelのバージョンが8になってルーティングの記載方法が変わったらしい。

ver7.x

web.php
Route::get('test/func','TestController@func');

ver8.x

web.php
Route::get('test/func', [TestController::class, 'func']);

しかしなぜかバージョン8の記法に変えてもエラーのまま。。。。
👆TestControllerをuseしていないことが原因(下記記載方法はフルパスだからuse無しでも大丈夫なのかな?)
そこで下記の記載もできるようなのでやってみると。。

web.php
Route::get('test/func','App\Http\Controllers\TestController@func');

Hello Worldが無事表示された!!

image.png

※なぜ新記法で表示されないのか知っていたら教えて下さいませ:disappointed:

参考

0
0
2

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?