0Pricing
PHP Academy · Lesson

Defining Routes in Laravel

Register GET, POST, and resource routes in web.php and api.php.

Basic Route

Define a GET route that returns a string response.

<?php
use Illuminate\Support\Facades\Route;

Route::get("/hello", function () {
    return "Hello, Laravel!";
});

HTTP Verb Methods

Laravel provides get, post, put, patch, delete, options route methods.

<?php
Route::post("/users", [UserController::class, "store"]);
Route::put("/users/{id}", [UserController::class, "update"]);
Route::delete("/users/{id}", [UserController::class, "destroy"]);

All lessons in this course

  1. Laravel Project Structure
  2. Defining Routes in Laravel
  3. Controllers and Actions
  4. Blade Templates and Views
← Back to PHP Academy