There are a number of solutions, like a change to index.php or the accepted one with the ioc container.
The solution that works best, in my opinion, is described in this SO question:
Laravel 5 change public_path()
Why is it better than other solutions? Because it works for regular http request, use of artisan ánd use of phpunit for testing! E.g. the change to index.php works only for http requests but leads to failures when using PHPunit (in my case: file (...) not defined in asset manifest).
A short recap of that solution:
Step 1: In the file: bootstrap/app.php change the very first declaration of $app variable from:
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
to:
$app = new App\Application(
realpath(__DIR__.'/../')
);
This points to your own custom Application class, which we will create in step 2.
Step 2: Create the file Application.php in the app folder:
<?php namespace App;
class Application extends \Illuminate\Foundation\Application
{
public function publicPath()
{
return $this->basePath . '/../public_html';
}
}
Be sure to change the path to your needs. The example assumes a directory structure like so:
°°laravel_app
°°°°app
°°°°bootstrap
°°°°config
°°°°...
°°public_html
In case of the OP, the path should probably be
return $this->basePath . '/../www/public';
(up one from laravel_app, then down into www/public)