6

I have looked at several answers suggested to a similar issue but nothing worked in my case. FYI, this is my first project in Laravel 7, working fine on my Mac. I have deployed the project on my server following this article. When running the project on the web, I get the following error :

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:258

Stack trace: #0 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(425): Illuminate\Support\Facades\Facade::__callStatic('replaceNamespac...', Array) #1 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(402): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths() #2 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(313): Illuminate\Foundation\Exceptions\Handler->renderHttpException(Object(Symfony\Component\HttpKernel\Exception\HttpException)) #3 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(210): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpKernel\Exception\HttpExcepti in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 258

How can I fix it?

4givN
  • 2,936
  • 2
  • 22
  • 51
Paul Godard
  • 1,055
  • 1
  • 14
  • 30
  • It might be a permission error, I don't know maybe SELinux error, did you try to disable it temporary like `> setenforce 0 ` if you are using centos you can search for the cmd if you are using other OS – PsyLogic Apr 28 '21 at 21:17
  • 1
    run the ```php artisan optimize ``` in console – dılo sürücü May 30 '22 at 15:47

5 Answers5

5

I finally found a solution that worked in my case.

  1. delete the folder vendor
  2. run composer update
  3. run php artisan config:cache
  4. run php artisan config:clear

Home page now displays but the routes do not work...

Kerim Kuşcu
  • 417
  • 4
  • 12
Paul Godard
  • 1,055
  • 1
  • 14
  • 30
0

If the solution from @Paul Godard doesn't work, it could be a psr/log issue as mine.

My composer update added psr/log v2.0.0, which requires php8. However, my application is on php7.4

That gave me the exact error output like in the description

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:258

My solution was to specify in composer.json that I'm using "psr/log": "^1.1.0"

Then run composer update

4givN
  • 2,936
  • 2
  • 22
  • 51
0

I got that error when my config folder was deleted by mistake. So after recovering the config folder. My project worked fine. You have to check if any folder is removed on which project is depending. Recover or copy it. It will work fine then.

M.Haris
  • 451
  • 4
  • 5
0

I tried all the way from all forum but none of them work, finally I resolve the issue.

Just rename your config folder as config_backup and just copy the config from a fresh Laravel project and paste it in your project folder then it will resolve.

0

This also happens when laravel has some errors at php level, like in the case of undefined constants in configuration files until the application even gets bootstrapped. In my case, I had "Undefined constant Redis::SERIALIZER_IGBINARY" in config/database.php. To solve that we have to install php redis module along with igbinary serializer for example.

eldorjon
  • 170
  • 2
  • 13