Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 877
Quasipickle Avatar asked Dec 05 '25 15:12

Quasipickle


1 Answers

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>
like image 51
prodigitalson Avatar answered Dec 08 '25 07:12

prodigitalson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!