Simply viewing Laravel in browser using Xampp Server, no php artisan serve

Laravel artisan commands

Last updated on October 17th, 2016 at 12:59 pm

You have just installed laravel in Xampp or Wamp. I will use Xampp to illustrate. You need to view the Xampp installation without firing up the server on cmd that is, >>php artisan serve.

view laravel in browser
view laravel in browser by serving through CMD

To view the Laravel installation on the browser using Xampp server you would normally have to type localhost/examplelaravel/public in most cases you don’t want to type ‘public’ all the time. In this short post I will show you how to get it to localhost/examplelaravel. You will be able to view your site without the public in the url

  1. Go into the laravel files folder then into public. Eg if you installed laravel in examplelaravel, you should go into the folder examplelaravel/public then locate index.php and copy the file to the root of your site laravel files, ie paste it in examplelaravel.
  2. Then open examplelaravel /index.php in an editor of your choice.

    changing index.php in laravel for xampp server
    edit index.php for laravel
  3. Go to line 21 and change it to as follows

 

require __DIR__.'/bootstrap/autoload.php';

 

  1. Go to line 35 and change it to as follows

 

$app = require_once __DIR__.'/bootstrap/start.php';

 

edit laravel to xampp
Edited both lines of laravel’s index.php
  1. You should now be able to visit localhost/examplelaravel and your site will load.

Needless to say, this tutorial is intended for use in your development environment just to make your work easier if you prefer to use Xampp or Wamp.

The following two tabs change content below.
Just a geek who loves Trance . Be yourself everywhere you go. And Be yourself in everything you do. Cheers !

Comment Here