Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cbj4074
Last active February 29, 2020 00:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbj4074/9bb210706f8f2fdd61b0 to your computer and use it in GitHub Desktop.
Save cbj4074/9bb210706f8f2fdd61b0 to your computer and use it in GitHub Desktop.
Changes required to use non-standard public directory in Laravel 5
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Custom/non-standard public and private directory definitions.
|--------------------------------------------------------------------------
|
| A few changes are required to use custom/non-standard directories for
| Laravel's "public" and "private" paths. These default values should work
| out-of-the-box, but may be changed to accommodate more complex configurations.
| For details, see:
| https://laracasts.com/discuss/channels/general-discussion/where-do-you-set-public-directory-laravel-5/replies/49083
|
| Note: Given that these paths may be environment-specific, it may be
| necessary to push an appropriately-tailored copy of this file into place
| as part of the build or deployment process.
|
*/
$relativePathToLaravel = '..';
$relativePathToPublic = '.';
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require realpath(__DIR__ .'/' . $relativePathToLaravel . '/bootstrap/autoload.php');
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once realpath(__DIR__ .'/' . $relativePathToLaravel . '/bootstrap/app.php');
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
@cbj4074
Copy link
Author

cbj4074 commented Oct 19, 2015

Of note is the fact that I also wrapped the arguments to the require() and require_once() calls in realpath() to fix problems on systems that enforce open_basedir restrictions in PHP.

My opinion is that this change should be made in the Laravel source, too. (Maybe I'll submit a PR.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment