Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on TumblrEmail this to someone

If you want to change or completely remove public directory in laravel 5 then you need to extend laravel’s application. Here is the simple steps to remove public directory. In the same way you can also change or rename public directory.

First, create an application class somewhere with a namespace and extend Illuminate\Foundation\Application

<?php namespace FindTuts;

class Application extends \Illuminate\Foundation\Application


Laravel initialized iIlluminate\Foundation\Application in bootstrap/app.php so you need to replace with your extended class.

$app = new Illuminate\Foundation\Application(

replace those lines with these:

$app = new FindTuts\Application(

Override Method
To change the path of public / web directory you need to override Method publicPath. Lets update application.php

<?php namespace FindTuts; 
class Application extends \Illuminate\Foundation\Application { 	
	 * Get the path to the public / web directory.
	 * @return string
	public function publicPath()
	   return $this->basePath;

Now copy all the files from public directory and paste into root directory, then remove public/ directory.

Lets update path in index.php

Open index.php which is in root directory. Replace below line

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';


require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

Well done you have successfully updated public path. In the same way you can extend anything else that the Application class provides to Laravel.