我在 AppServiceProvider 中覆盖了 public_path() $ this-> app-> bind('path.public',function(){返回base_path().'/';}); 但是什么都没有改变.解决方案您可以通过将公用文件夹添加到通常在/public文件夹中找到的index.php文件中来正确绑定公用文件夹 //设置此目录的公共路径$ app-> bind('path.public',function(){返回__DIR__;}); I moved Laravel's public folder to the root folder, and I moved Laravel to its own folder. So I can use Laravel on a shared hosting. It looks like this:2015/08/04 18:13 <DIR> .2015/08/04 18:13 <DIR> ..2015/08/01 17:50 896 .htaccess2015/07/29 17:39 0 favicon.ico2015/07/29 17:39 1,844 index.php2015/08/04 17:19 <DIR> laravel2015/08/04 17:20 <DIR> public2015/08/01 17:46 1,165 README.md2015/08/01 16:18 34 robots.txt2015/08/04 17:20 <DIR> staticFor example, I'm using public_path() and I get this:but what I need is this:I've checked config files in /config/ but there is nothing about it.Please tell me how to fix it. thx(My laravel version is 5.0.33)PS:I've tried this method:Laravel 5 on shared hosting - wrong public_path()I overwrited public_path() in AppServiceProvider$this->app->bind('path.public', function() { return base_path() . '/';});But nothing changed. 解决方案 you can bind the public folder correctly by adding this to the index.php file in usually found in your /public folder// set the public path to this directory$app->bind('path.public', function() { return __DIR__;}); 这篇关于如何在Laravel 5中设置基本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 12:51
查看更多