On laravel 9 site I need to get the current user in AppServiceProvider.
I know that usually current user is not available in AppServiceProvider.
I found this branch Laravel - How to get current user in AppServiceProvider it propose a way like :
...
use Illuminate\Support\Facades\View;
public function register()
{
//compose all the views....
view()->composer('*', function ($view)
{
\Log::info('View in register ');
});
}
public function boot()
{
//compose all the views....
view()->composer('*', function ($view)
{
\Log::info('View in boot ');
});
}
But none of the events is triggered and I do not see any log messages. Actually that is API project with passport and it does not use views... Do I see set additive options/packages/etc ?
"laravel/framework": "^9.26.1",
"laravel/passport": "^10.4.1",
Thanks in advance!