[請益] 簡單的Laravel程式無法執行已刪文

看板PHP作者 (只有音樂相伴)時間5月前 (2023/11/08 20:48), 5月前編輯推噓2(205)
留言7則, 3人參與, 5月前最新討論串1/1
小弟寫了一個簡單的Laravel程式 但無法執行 請大家看看問題在哪裡呢 建立Laravel框架環境的步驟 https://hackmd.io/@XchkZGnHT56qnXYLoFJM_A/HyMWC7eAD ------- public/index.php-------- <?php echo "index 1"; define('LARAVEL_START', microtime(true)); ------------routes/web.php-------- Route::group(['prefix' => 'user'], function(){ // 使用者驗證 Route::group(['prefix' => 'auth'], function(){ Route::get('/sign-up', 'UserAuthController@signUpPage'); Route::post('/sign-up', 'UserAuthController@signUpProcess'); }); }); ----------app/Http/Controllers/UserAuthController.php <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; class UserAuthController extends Controller { // 註冊 public function signUpPage(){ $binding = [ 'title' => 'my register', ]; return view('auth.signUp', $binding); } -------resources/views/auth/signUp.blade.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> Shop Laravel</title> </head> <body> <div class="container"> <form action="/user/auth/sign-up" method="post"> <label for="nickname">nickname</label> <input type="text" name="nickname" placeholder="{{ trans('shop.user.fields.nickname') }}" > </form> </div> </body> </html> ---------執行方式及結果 先到目錄下執行php artisan serve 然後到瀏覽器輸入 http://127.0.0.1:8000/sign-up 結果只會秀出 index 1 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.143.129.81 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1699447732.A.BE8.html ※ 編輯: afred (220.143.129.81 臺灣), 11/08/2023 20:49:09

11/09 00:01, 5月前 , 1F
你index.php 為甚麼要echo…
11/09 00:01, 1F
這樣才知道有執行到index.php

11/09 00:01, 5月前 , 2F
然後你signup 的middleware 怎麼設定的…
11/09 00:01, 2F
這要怎麼設 有連結嗎

11/09 00:01, 5月前 , 3F
我看了你貼的教學,你根本做的跟他教的兩回事吧
11/09 00:01, 3F
程式碼是看書的 教學只有安裝

11/09 00:02, 5月前 , 4F
然後你路由寫了一堆prefix…都不用?
11/09 00:02, 4F
這是書上寫的 後面章節可能會用到

11/09 07:03, 5月前 , 5F
/user/auth/sign-up
11/09 07:03, 5F
sorry 不懂您的意思 可以請你再解釋一下嗎

11/09 17:29, 5月前 , 6F
樓上的意思是根據你的route, 網址要像他這樣寫
11/09 17:29, 6F
我試了 http://127.0.0.1:8000/user/auth/sign-up 還是不行說 ※ 編輯: afred (220.143.129.81 臺灣), 11/09/2023 18:27:00

11/09 20:00, 5月前 , 7F
檢查 storage/logs/laravel.log,看看錯誤訊息比較清楚
11/09 20:00, 7F
剛檢查過了 laravel.log沒有這兩天的錯誤訊息 ※ 編輯: afred (220.143.129.81 臺灣), 11/09/2023 22:34:38
文章代碼(AID): #1bIuEqle (PHP)
文章代碼(AID): #1bIuEqle (PHP)