Skip to main content

Command Palette

Search for a command to run...

Routing

Part -1

Updated
1 min readView as Markdown
Routing
L

I've got accomplished web development with expertise in various programming languages including PHP, Laravel, C#, and C++. My curiosity to learn more and my passion for coding drives me to constantly enhance my skills and create exceptional digital experiences.

Routing types

We'll start with the basics and gradually move towards advanced routing techniques, providing you with a comprehensive understanding of Laravel's routing capabilities. So, stay tuned and take your Laravel skills to the next level!

Primary Route

    1. Basic Route

      1. Default Route Files

      2. Redirect Routes

      3. View Routes

      4. Route list

  • Basic Route

//Write this code in laravel Project[Resources/routes/web.php]
//Route below will return you Hello World
Route::get('/greeting', function () {
    return 'Hello World';});

  • Default Route Files

Routes/web.php ->defines = interface and assigned to web middleware group.[web-middleware provides session states and CSRF]

Routes/api.php -> are stateless and are defined in the route service provider [/api prefix is automatically added] ->routeserviceprovider helps API route to carry its functions out

  • Redirect Routes


Route::redirect('/here', '/there');
//Route::redirect('uri', 'destination');
Route::permanentRedirect('/here', '/there');//Code will be 302=means resources is moved to url header.
Route::redirect('/here','/there',302);
  • Route view


Route::view('/welcome', 'welcome', ['name' => 'Taylor']);
//name=>'Taylor is an array'
  • Route list

Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);