1
1

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.

Laravel9から大幅にルーティングの書き方が変わった

Last updated at Posted at 2022-04-18
routes\web.php
<?php
use App\Http\Controllers\HomeController;//名前空間

Route::get('/home',[HomeController::class,'index']);

ルートを変えたらキャッシュクリアしないと反映されないです。

$ php artisan route:cache
Homecontroller.php
class HomeController extends Controller
{
    //
   public function index()
   {
     $message = 'Hello World';
     return view('home.index',['message' =>$message]);
   }
}
views\home\index.blade.php
<html>
<body>
     <h1>{{$message}}</h1>
</body>
</html

urlは http://127.0.0.1:8000/homeで表示されました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?