You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I want to adhere to the principle of dependency injection, and add Spatie\Permission\Models\Role to the __construct of any class, I will get an error Fatal error: Uncaught ReflectionException: Class "config" does not exist
Because the helper config() is not initialized yet at the moment.
A simple example:
namespaceApp\Services\Permission;
class PermissionService
{
publicfunction__construct(
private\Spatie\Permission\Models\Role$role,
) {
}
}
Now in the terminal, try typing a command, for example php artisan cache:clear, and you will get an error.
I have a solution, I will offer it in PR ))
@systemsolutionweb Yes, I looked more closely and found that only using dependency injection in the code does not give such an error. But if you use this PermissionService class in DI in the App\Console\Kernel constructor, then there will be an error with any access to the terminal.
If I want to adhere to the principle of dependency injection, and add
Spatie\Permission\Models\Role
to the __construct of any class, I will get an errorFatal error: Uncaught ReflectionException: Class "config" does not exist
Because the helper
config()
is not initialized yet at the moment.A simple example:
Now in the terminal, try typing a command, for example
php artisan cache:clear
, and you will get an error.I have a solution, I will offer it in PR ))
Versions
laravel/framework - v8.83.11
spatie/laravel-permission - 5.5.3
PHP 8.0.8
Windows 11
The text was updated successfully, but these errors were encountered: