Currently I’m converting my Laravel 4 application to Laravel 5. When finding tricks or goofs I will post it to this blog.
One of the first thing I’m doing after installing Laravel is changing the public directory. In Laravel 4 it was pretty straight forward, just edit the bootstrap/paths.php
. Unfortunately in Laravel 5 it’s a bit more tricky, but not that hard either.
In my case, I need to rename the public
folder to public_html
. So everywhere I change public
you can change it to the directory you want:
- Open
public/index.php
- Add:
$app->bind('path.public', function() { return base_path() . '/public_html'; });
- Open up
server.php
from the root directory of your Laravel installation. - Change:
if ($uri !== '/' and file_exists(__DIR__.'/public'.$uri)) {
To:
if ($uri !== '/' and file_exists(__DIR__.'/public_html'.$uri)) {
And change the last line from:
require_once __DIR__ . '/public/index.php';
To:
require_once __DIR__ . '/public_html/index.php';
PHP knows the new public folder. There’s one more thing to do, we need Elixir to tell where to find the assets.
- Open
gulpfile.js
- After:
var elixir = require('laravel-elixir');
Add:
elixir.config.publicDir = 'public_html';
The only thing to do now, is to rename the folder.
This solution will not work when using
php artisan serve
. I will create an updated blog post soon.
There is no base_patch() function. It is only base_path(). In spite of this issue works like a charm!