Laravel 5.6 Uncaught RuntimeException:尚未设置外观根.在供应商/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218中 [英] Laravel 5.6 Uncaught RuntimeException: A facade root has not been set. in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218

查看:430
本文介绍了Laravel 5.6 Uncaught RuntimeException:尚未设置外观根.在供应商/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用作曲家在PHP 7.1.8(fedora 23)上安装Laravel 5.6后,当我尝试在浏览器中打开url时,出现此错误

After installing Laravel 5.6 on PHP 7.1.8 (fedora 23) using composer, when I try to open url in browser, I get this error

PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set. in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218\nStack trace:  
\n#0 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(396): Illuminate\\Support\\Facades\\Facade::__callStatic('replaceNamespac...', Array)  
\n#1 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(373): Illuminate\\Foundation\\Exceptions\\Handler->registerErrorViewPaths()  
\n#2 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(288): Illuminate\\Foundation\\Exceptions\\Handler->renderHttpException(Object(Symfony\\Component\\HttpKernel\\Exception\\HttpException))  
\n#3 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(187): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(Symfony\\Co in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218

我已经使用composer安装了Laravel,并且安装时没有错误.所有目录都具有足够的权限(我刚刚授予了Laravel官方安装指南所指定目录的写权限,以使用apache.)

I have installed Laravel using composer and there were no error while installation. All directories have enough permissions (I've just granted write permission to apache for directories specified by official Laravel installation guide.)

我该怎么做才能解决此错误?

What should I do to fix this error?

推荐答案

尝试了很多之后,我意识到这是由于我的系统中使用了SELinux造成的问题. SELinux阻止apache写入所需的文件.

After trying a lot, I realized this was an issue due to SELinux in force in my system. SELinux prevented apache from writing to required files.

$ /usr/sbin/getenforce
Enforcing

我禁用SELinux以确认该怀疑,并且在SELinux被禁用后它可以正常工作.因此,我只需要为我的项目设置适当的权限,以便SELinux可以允许apache写入必要的文件.

I disabled SELinux to confirm this doubt and it worked properly once SELinux was disabled. So I just needed to set proper permission for my project, so SELinux can allow apache to write to necessary files.

$sudo chcon -t httpd_sys_rw_content_t /path/to/my/laravel/project/dir -R

我希望这对面临同样问题的人有所帮助.

I hope this will help to those who are facing same issue.

这篇关于Laravel 5.6 Uncaught RuntimeException:尚未设置外观根.在供应商/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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