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

Last updated on October 30th, 2020 at 04:16 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.

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.
  3. Go to line 21 and change it to as follows
require __DIR__.'/bootstrap/autoload.php';
  1. Go to line 35 and change it  as follows
$app = require_once __DIR__.'/bootstrap/start.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.

Update 2018: 

It’s been three years since I used Laravel. If this doesn’t work anymore, my apologies. Let me know in the comments. Right now I am more involved with Server Management, Digital Marketing Tools, Front End Web Technologies, JS and JS Frameworks . Hence I have no plan to review PHP or Laravel anytime soon.

If it doesn’t work and you find a solution, paste it in the comments and I will update the post and credit it to you.

Comment Here

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!