0

I received a project from my client. I tried to install it in my local machine using php artisan serve command and I found below error

enter image description here

After searching in Google I found this question. Then I found that there is no public folder in my project directory.

enter image description here

Is there any specific reason to delete this public folder ? or it is left accidentally ?

I changed

chdir($this->laravel->publicPath());

in vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php To :

chdir('/');

as per this question. After that I am getting a blank white page while I am running my project using php artisan serve.

What is the solution ?

abu abu
  • 6,599
  • 19
  • 74
  • 131

2 Answers2

3

They probably tried setting up the app to run from the root directory, instead of public folder. Usually happens when a Laravel app is setup to run (incorrectly i might add) on shared hosting.

create a new public directory & move your js, css & index.php files back into it. Also check for any explicit paths that reference index.php from the root directory & update them so they point to the public dir instead. You'll also have to create a new htaccess file (or move the existing one from root) in your public dir .

Just compare with the dir structure of a clean laravel install and you'll be able to see what you're missing.

Eddie Padin
  • 645
  • 1
  • 8
  • 13
3

Most new developers are using this method for hiding the public folder in real server due to lack of experience. I suggest you edit back the main folder to "public" from '/'

Firstly, look at your index.php file and replace

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

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

2) Change require 'vendor/autoload.php';

to

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

3) Create a new public folder and put your asset files and index.php there.

You can try php artisan config:clear after those steps.

Don't forget the main purpose is getting back the public folder.

Diamond
  • 7,428
  • 22
  • 37
Murad Shukurlu
  • 417
  • 6
  • 11