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

willaguilar's avatar

Roles & Permissions

Could anyone help with the following... I'm building a web app where I need to use Roles & Permissions. In the past I successfully deploy the [Zizaco/Entrust] (https://github.com/Zizaco/entrust) in one of my projects. Unfortunately, I haven't been able to figure out how to get Entrust to use caching so I'm making a bunch of calls to my database to check permissions which has made my app very slow (the database and the app server are not in the same network sadly).

I have read and read the Gates & Policies documentation but haven't found if I will run with the same problem of hitting my DB with too many calls just to check permissions and roles.

I also read about [Bouncer] (https://github.com/JosephSilber/bouncer) which does support caching but I don't necessary want to be tied to a third package.

Any help and comments will be greatly appreciated.

0 likes
1 reply
mix359's avatar

Uhm, I haven't used entrust, but it seam similar to another system I'm using. Suddenly many of this system doesn't have any caching ability (from what I know, laravel doesn't use the caching system too much... it simply offer the utility to use it, but it doesn't integrate it with something for example the query result caching... so the packet written for laravel rarely use the cache)

If you don't want to change your permission system, I suggest to try to overwrite the model it's using (in my system I can extend them and pass the new Model through the configuration of the system) Or maybe you can do the same thing with the event system. In this way you can intercept the data queried to those model and cache them. But you also have to delete those data when you change something (like a role or a user-role association).

Hope that can help ;)

Cheers Daniele

Please or to participate in this conversation.