Laravel Basic of Route and View

Laravel Basic of Route and View

Consider any URL send request form the browser and go to server and that server use Laravel as a backend and perform the following steps:

  1. Route File looks at the request: Request first of all goes to route file and it looks the request and decide what to do next
  2. Get or process any data needed: Then it processes some data and save it to database or retrieve data or something else
  3. Compile a view to return: At Last we could inject it into view which is Just an HTML Template, compile that and return it to the user so they can see in the browser

Let’s do some practical work

  1. Go to Routes Folder and there is different file we will work on web. Php file
  2. There is one route setup and we do this using the Route class and there is a method called get with 2 parameters first is route (‘/’, ‘/contact’) and next is callback function that return a view.
  3. These views are placed in resources folder
  4. Click on the view folder and there is file with name welcome.blade.php.
  5. Here welcome is the name of view
  6. blade is template engine
  7. php is extension

This page is just HTML with some blade syntax and dynamic content

Example

           Route::get(‘/’, function(){

           return view(‘welcome’);

           })

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*