2025年5月30日 星期五

laravel 12 route 路由

路由是應用程序的入口點,用於定義客戶端請求特定URI 時的響應邏輯。路由將URL 映射到對應的處理代碼,通常包含HTTP 方法、URI 和動作(閉包或控制器方法)。

測試指令:
php artisan serve

檔名:routes/web.php
內容:
Route::get('/',function(){
    return "Hello! World";
});
Route::get('about',function(){
    return "about us";
});

Route::prefix('details')->group(function(){
    Route::get('students',function(){
        return "this is student";
    })->name('student-Details');
    Route::get('teachers',function(){
        return "this is teacher";
    })->name('teacher-Details');
});

Route::get('student/{id}/{reg}',function($id,$reg){
    return 'student number '.$id. ' registration number '.$reg;
});

Route::fallback(function(){
    return "This page is no found please try again";
});

顯示所有可用路由指令:
php artisan route:list


此時,在瀏覽器網址列輸入http://127.0.0.1:8000/up






資料來源:

沒有留言:

張貼留言

在 192.168.91.x/24 網段,架設兩台DNS。當Master變更,讓client電腦對Slave 進行變更後的正解與反解

系列文章: 1.在 Ubuntu 26.04 架設網域名稱伺服器(DNS)及相關設定說明 2.在 192.168.91.x/24 網段中,架設DNS,讓client電腦進行正解與反解 3. 在 192.168.91.x/24 網段,架設兩台DNS。當Master變更,讓clien...