Laravel 5.2避免使用公用文件夹并直接从本地主机的根目录打开 [英] Laravel 5.2 Avoiding public folder and open directly from root in localhost

查看:89
本文介绍了Laravel 5.2避免使用公用文件夹并直接从本地主机的根目录打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样做的原因是Laravel has the document root in a subdirectory is so that you don't have to expose your code to the public.

我的本​​地主机中的文件夹结构为

The folder structure in my localhost is

Test
    Test/laravel/
    Test/public_html/

其中laravel包含root的所有文件夹,不包含公共文件夹,而public_html包含公共文件.

where laravel contains all the folder of root without the public folder and public_html contains the public files.

我在public_html/index.php的以下几行中进行了更改:

And I have changed in below lines in public_html/index.php:

require __DIR__.'./../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'./../laravel/bootstrap/app.php';

我遵循了解决方案解决了问题,但由于我使用的是5.2,因此无法解决.如果有人这样做过,请提供有效的解决方案.

I have followed the solution for solving the problem but couldn't solve it as I'm using 5.2. If anyone has done this before please provide a valid solution.

提前谢谢.

推荐答案

Laravel已随附公共目录(可以轻松重命名为public_html).但是,查看您的代码,问题出在**./**../laravel/bootstrap/autoload.php'

Laravel already comes with the public directory (which would be easily renamed public_html). However, looking at your code, an issue lies at **./**../laravel/bootstrap/autoload.php'

这将以类似于Test./的目录结尾,而不是Test/.删除第一个斜杠之前的句点.

This would end up with a directory like Test./ instead of Test/. Remove the period before the first slash.

require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

这篇关于Laravel 5.2避免使用公用文件夹并直接从本地主机的根目录打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆