I don't see why not. They can only be changed in code (php), meaning users can't change them.
The important part is just to make sure to check for these properly using gates :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have to affect some roles to the users. I know the spatie package, but it's not necessary for me.
I ask myself about security.
Is it secure to define some roles in a roles.php file in the config folder ?
Like this one ?
<?php
return [
'ADMIN' => [
'title' => 'Administrateur',
'code' => 1,
],
'SUPERADMIN' => [
'title' => 'Super-Administrateur',
'code' => 2,
],
'AUTHOR' => [
'title' => 'Auteur',
'code' => 3,
],
'PLAYER' => [
'title' => 'Joueur',
'code' => 4,
],
'default' => 4,
];
Or is it better to have a role model (but not necessary for me because there will never be other roles and there is no need for the admin to manage / add / ... the roles from the app) ?
Thanks for your answer.
Vincent
I don't see why not. They can only be changed in code (php), meaning users can't change them.
The important part is just to make sure to check for these properly using gates :)
Please or to participate in this conversation.