Laravel 5.6 Uncaught RuntimeException: A facade ro

2020-04-21 06:03发布

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

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?

1条回答
仙女界的扛把子
2楼-- · 2020-04-21 06:23

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

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.

查看更多
登录 后发表回答