質問編集履歴
1
.envファイルなど追記
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Laravel
|
1
|
+
Laravelローカル環境で404が出る
|
body
CHANGED
@@ -6,18 +6,45 @@
|
|
6
6
|
laravelの404エラー画面がでます。
|
7
7
|
(なんか変なところでつまづいている気がします、、、)
|
8
8
|
|
9
|
+
##追記
|
10
|
+
やはりルーティングはあってるような気がします。
|
11
|
+
下記ソースでhttp://localhostにアクセスしても404になってます。
|
9
12
|
|
10
13
|
|
14
|
+
|
11
15
|
##ソース
|
16
|
+
```
|
17
|
+
#web.php
|
18
|
+
<?php
|
19
|
+
|
20
|
+
declare(strict_types=1);
|
21
|
+
|
22
|
+
use App\Http\Controllers;
|
23
|
+
use Illuminate\Routing\Router;
|
24
|
+
use Illuminate\Support\Facades\Route;
|
25
|
+
|
26
|
+
/*
|
27
|
+
|--------------------------------------------------------------------------
|
12
|
-
|
28
|
+
| Web Routes
|
29
|
+
|--------------------------------------------------------------------------
|
30
|
+
|
|
31
|
+
| Here is where you can register web routes for your application. These
|
32
|
+
| routes are loaded by the RouteServiceProvider within a group which
|
33
|
+
| contains the "web" middleware group. Now create something great!
|
34
|
+
|
|
35
|
+
*/
|
36
|
+
|
13
37
|
Route::prefix('drinks')->name('drink.')->group(
|
14
38
|
function (Router $router) {
|
15
39
|
$router->get('/', [Controllers\DrinkController::class, 'index'])->name('index');
|
40
|
+
$router->post('/buy/{id}', [Controllers\DrinkController::class, 'buy'])->name('buy');
|
16
41
|
}
|
17
42
|
);
|
43
|
+
|
18
44
|
```
|
19
45
|
|
46
|
+
```
|
20
|
-
|
47
|
+
#Controllers\DrinkController
|
21
48
|
<?php
|
22
49
|
|
23
50
|
declare(strict_types=1);
|
@@ -52,6 +79,10 @@
|
|
52
79
|
}
|
53
80
|
|
54
81
|
}
|
82
|
+
```
|
55
83
|
|
84
|
+
```
|
85
|
+
#.env
|
86
|
+
APP_URL=http://localhost
|
56
87
|
|
57
88
|
```
|