Menu

Laravel 5 to 8 change public_path()

Written by

Issue

When trying to move the public folder to other place. However, You can’t find the place to modify public_path() variable. Now, the ‘public_path()’ return the wrong path of folder.

 

Solution

I suggest you add it in

app/Providers/AppServiceProvider.php:

Add the following line in the register() method

public function register()
{
    $this->app->bind('path.public', function() {
        return realpath(base_path().'/../public_html');
    });
}

 

Article Categories:
Laravel

Leave a Reply

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

Shares