我使用的是一个共享主机,它使用cPanel作为控制面板,cPanel public_html
中是默认的根目录,因此我无法让我的Laravel应用程序正常工作.
有没有办法让Laravel使用public_html
而不是公用文件夹?
我使用的是一个共享主机,它使用cPanel作为控制面板,cPanel public_html
中是默认的根目录,因此我无法让我的Laravel应用程序正常工作.
有没有办法让Laravel使用public_html
而不是公用文件夹?
通过简单的搜索很容易找到这个.
在index.php中添加以下3行.
/*
|--------------------------------------------------------------------------
| 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 __DIR__.'/../bootstrap/app.php';
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
编辑:
正如Burak Erdem提到的,另一个 Select (更可取)是将其放入\App\Providers\AppServiceProvider
register()
方法中.
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// ...
$this->app->bind('path.public', function() {
return base_path('public_html');
});
}