Where should I define ACL for Pages?


When I create navigation, I can happily use a ready-made factory to use a configuration file like as follow.

    'navigation' => [
        'default' => [
                'label' => 'HOME',
                'controller' => 'home',
                'action' => 'index',
                'resource' => 'guest',

But when I create ACL, I can’t find a ready-made factory for ACL using such a
configuration file as follows.

'acl' =>[
        'roles' => [
            'guest'          =>  [],
            'user'            =>  ['guest'],
            'admin'    =>  ['user'],
        'resources' => [

If so, I have to define ACL myself somewhere.

The “navigation helper factory” or the “despatch event listener” comes to my mind.

Where should I define ACL for Pages?

Unfortunately, there is no factory in the laminas-permissions-acl component at the moment, but it is planned.
But you can adopt the configuration from mezzio-authorization-acl:


The you can copy and modify the factory:

And to set the ACL for the navigation helpers, you can use this delegator:

1 Like

guest is not a resource, but a role. According your ACL configuration, you have to use guest.action or something similar.

1 Like

Thank you for your suggestion again.

Thanks to your help, the base of our project are almost complete :fist:

Humm, when we start new project, should we use Mezzio rather than MVC?

Oh, I found a document.

I’ll read it.

I like Laminas because it doesn’t have buzzy frequent updates compared to other frameworks.

But now, there are few information of Mezzo in Japanes (Laminas MVC, too), and this gives the feeling that the threshold is higher for the ordinary engineer (include me). If I had sufficient language skills, I could make some kind of contribution…