Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Abdellah's avatar

A facade root has not been set.

Hello devs, please help me solve this problem for I can't pass it. Thanks.

0 likes
18 replies
Braunson's avatar

Is this a fresh Laravel 7.x install, or are you upgrading from a previous version? What version are you using now?

Try running these first:

 php artisan config:cache
 php artisan config:clear
 php artisan cache:clear
 composer update
1 like
bobbybouwmann's avatar

We need more information to help you...

Are you using Lumen? If so did you uncomment $app->withFacades(); in app.php

3 likes
Abdellah's avatar

artisan commands also send the above errors.

Abdellah's avatar

no it's a laravel 5.8 project and it's maintained in the company. The maintainer has no clue also. I have tried everything and he says he cannot update to a newer version of Laravel because some dependencies will be broken.

bobbybouwmann's avatar

Check if the facades are registered in the config/app.php directory.

2 likes
Abdellah's avatar

I see all facades present in the alias array. I don't know if that is what you mean. Thanks.

1 like
martinbean's avatar

@abdellah Still need more information. If the application is throwing an exception, then it’ll give you a stack trace for you to find what piece of code is actually triggering that error.

You can’t just post a snippet of an error message with no context and expect someone to magically know what the problem is and how to fix it.

1 like
Abdellah's avatar

@martinbean I truly can't find more information except that message I get from the terminal. Thank you.

Abdellah's avatar

@martinbean here is the log

[stacktrace]
#0 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\config\seotools.php(14): Illuminate\Support\Facades\Facade::__callStatic('get', Array)
#1 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(72): require('C:\\Users\\Abdell...')
#2 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(39): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\Foundation\Application), Object(Illuminate\Config\Repository))
#3 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(210): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))
#4 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(322): Illuminate\Foundation\Application->bootstrapWith(Array)
#5 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(131): Illuminate\Foundation\Console\Kernel->bootstrap()
#6 C:\Users\Abdellah Ramadan\Desktop\COMPANY\poblysh\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 {main}```



and this is where the error is coming from in Facade.php :



```public static function __callStatic($method, $args)
    {
        $instance = static::getFacadeRoot();

        if (! $instance) {
            throw new RuntimeException('A facade root has not been set.');
        }

        return $instance->$method(...$args);
    }```
bobbybouwmann's avatar

@abdellah Looking at the error it seems there is a mistake in the config/seotools.php file on line 14. At least, that's where the error is triggered. It seems it can't load the configuration.

1 like
neoresearcher's avatar

In my case it was a simple matter of enable to load the config file. I made some changes in the database.php file in the app/config. Database.php return an array; so i though i would return one array if the env is local and another array if env is online. for that i used if (App::environment('local')) { } else {} to use App I included use Illuminate\Support\Facades\App;

at the top and this made all the fus. I think framework is loading those config files way before it does any other thing and that why using the if statement didn't work which caused that problem. removing the if from database.php also removed the error.

mstroink's avatar

Same error when you forget to call the parent::setUp() in your setUp method while running tests.

    public function setUp(): void
    {
        parent::setUp();
    }
2 likes
rfiedler's avatar

I my case, i got this exception becouse i change the path name before install laravel. Create new laravel project and Voilá !

jjudge's avatar

Scratched my head about this one for a while. The cause is that a facade is being used before the facades have been loaded. But which facade? Knowing that would help somewhat. The error message does not give any clues, so change the error message.

In the Illuminate Support class here (vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php):

https://github.com/laravel/framework/blob/10.x/src/Illuminate/Support/Facades/Facade.php#L350C75-L350C75

the error message can be changed from:

throw new RuntimeException('A facade root has not been set.');

to

throw new RuntimeException(sprintf('A facade root has not been set for %s', static::class));

This will then give you the FQDN of the facade being used early. Then you can search for that facade in your code - perhaps in a config file, or used in an error handler with an exception being thrown very early in the boot process.

That link above is from the 10.x branch, so it's long overdue a PR to put in this additional information for a tiny but useful improvement.

Just a note: usually you will have the stack trace, which may be enough to find where the trait is used. Sometimes you don't get a stack trace or error log, which can be because the error handling and loggig also have not yet been set up, and all you get is this single message.

1 like

Please or to participate in this conversation.