This is what I did to change the name AND location of the public folder in Laravel 5.1:
Step 1: Edited these 2 lines in public/index.php to the following:
require __DIR__.'/../usr/laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../usr/laravel/bootstrap/app.php';
Note that I also edited the $app path. It now points to the same location as the line above it (my Laravel root folder).
Step 2: Created app/MyApp.php with the content that sid405 wrote:
<?php namespace App;
use Illuminate\Foundation\Application;
class MyApp extends Application
{
public function publicPath()
{
return $this->basePath.DIRECTORY_SEPARATOR.'www';
}
}
Step 3: In bootstrap/app.php commented out the default application and replace it with:
// $app = new Illuminate\Foundation\Application(
// realpath(__DIR__.'/../')
// );
$app = new App\MyApp(
realpath(__DIR__.'/../')
);
Step 4: There wasn't a compiled.php file present in my Laravel project, so no action taken there. About dumping the autoloader.. I'm unable to run composer on my production server, so I executed the following command on my localhost:
composer dump-autoload -o
Step 5: Uploaded the entire Laravel folder via FTP to the production server and made sure that the contents of the /public/ folder are located in my hosting providers public root. After navigating to www.mydomain.com I got an error 500 (internal server error), but this was solved by using Laravel's alternative .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I hope these steps are a correct and complete solution for changing the name and location of Laravel's public folder. However, any additional feedback is highly appreciated.