You were calling facades directly with the global namespace operator:
`\Log::info('message');
\DB::table('users')->get();`
Without declaring:
use Illuminate\Support\Facades\Log;
And it used to work.
Why?
Because Laravel used to auto-alias core facades like Log
, DB
, etc., via class aliases in the config.
❌ Why it’s failing now:
As of Laravel 10+ and PHP 8.2+, especially Laravel 12, automatic aliasing of facades like Log
and DB
is no longer guaranteed unless explicitly defined in your app.
Laravel removed global aliases from config/app.php
in recent versions for performance and clarity. So if you use \Log or \DB without importing them or aliasing them manually, PHP just says:
“Hey, I don’t know what Log is. Class not found.”
How to make it behave like before .
Option 1: Import Facades Explicitly .
Option 2: Restore Class Aliases in config/app.php
Steps
1 . Open config/app.php
2. Scroll to the aliases
array
3. Add the missing facades:
'Log' => Illuminate\Support\Facades\Log::class,
'DB' => Illuminate\Support\Facades\DB::class,
Now you should be able to use:
\Log::info(...);
as you want