Quasipickle
Quasipickle

Reputation: 4498

Laravel: supported way to change framework/app folder location?

I'm just starting to play around with Laravel and noticed in the docs it said they recommend you move your app files outside the document root, with just the content of /public being accessible. Ok, fine, so I've done that. However, looking in /public/index.php it is hard-coded to point up one directory to the /bootstrap directory. Since I've moved the framework code elsewhere, I modified the file slightly to:

$app_path = $_SERVER['DOCUMENT_ROOT'].'/../securefiles/myApp/';
...
require $app_path.'/bootstrap/autoload.php';
... etc ...

Is this the expected practice? This file needs to be set up correctly before Laravel even loads, so I don't imagine I can configure Laravel itself to know where it's stored relative to /public/index.php. I'm just curious though if there's another, better, more appropriate method?

Upvotes: 3

Views: 1902

Answers (1)

prodigitalson
prodigitalson

Reputation: 60413

No thats not what they mean. They mean that you need to point the virtualhost to use public as the DOCUMENT_ROOT leaving the rest of the structure intact. So you would see something like this:

projectname/
  app/
  bootstrap/
  public/

And then the apache/nginx/lighthttpd virtualhost configuration would set the DOCUMENT_ROOT to /path/to/projectname/public. So there would be no need to change anything really other than your server configuration. That is typically how its done. Apache example:

<VirtualHost *:80>
    DocumentRoot "/path/to/projectname/public"
    ServerName yoursite.com
    ServerAlias www.yoursite.com
</VirtualHost>

Upvotes: 4

Related Questions