📕
Sprnva Docs
  • Introduction
  • What's New?
  • Installation
    • Requirements
    • Download Sprnva zip no composer required
    • Install Sprnva Using Composer
    • Setup Config
  • Deployment
  • File Structure
  • Database
    • Select
    • SelectLoop
    • Insert
    • Update
    • Delete
    • Query
    • Seeder
    • Paginate
    • With
    • andFilter
    • withCount
    • get
  • Query Builder
  • Migration
    • INSTANCES
      • NEW
      • RENAMETABLE
      • DROP
      • CHANGE
    • DUMPS
      • dump
      • dump prune
    • MAKE
    • MIGRATE
      • migrate
      • migrate fresh
    • ROLLBACK
  • Routing
    • with parameter
    • multiple parameters
    • with closure
    • group
    • controller grouping
  • Controllers
    • methods
  • Views
    • Passing Parameters
  • Validation
    • validate
      • validation type
  • Authentication
  • Alert Messages
  • Default Helpers
  • CSRF Protection
  • Email
  • Packages
    • Fortify
  • Themes and Templates
Powered by GitBook
On this page

Routing

Sprnva has a beautiful routing built in. Route is our traffic control of our application that tells the entire application which page to be loaded when we hit a certain url.

You will find the routes at config/routes/web.php. Then this is how you declare a basic route.

Route::get('/uri', ['Controller@method', ['middleware']]);

/uri - the route you want to define.

['Controller@method', ['middleware']] - the action of the /uri

middleware - handles the protection of our routes basically our guardians.

Middleware Present:

  • auth : is the route guardian to protect your routes from direct access in the URL without authentication. If not specified the route will be accessible without authentication.

Sprnva routing supports this following methods:

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

This is what a basic route look like:

// routes is accessible without authenticating
Route::get("/register", ['RegisterController@index']);
Route::post("/register", ['RegisterController@store']);

// routes is accessible only if authenticated
Route::get("/profile", ['ProfileController@index', ['auth']]);
Route::post('/profile', ['ProfileController@update', ['auth']]);

where profile route is protected by middleware auth. It means you cannot access this route directly in the URL without authenticating.

PreviousROLLBACKNextwith parameter

Last updated 2 years ago