# Where should I define ACL for Pages?

**URL:** <https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336>\
**Category:** Components & MVC\
**Tags:** laminas-permissions-acl\
**Created:** [June 7, 2021, 5:01am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336 "2021-06-07T05:01:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smj320](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/smj320/32/914_2.png) [@smj320](https://discourse.laminas.dev/u/smj320)\
**Post date:** [June 7, 2021, 5:01am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/1 "2021-06-07T05:01:30Z")

</div>

Hi.

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

```auto
    '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.

```auto
'acl' =>[
        'roles' => [
            'guest' => [],
            'user' => ['guest'],
            'admin' => ['user'],
        ],
        'resources' => [
            'admin.action',
            'user.action',
            'guest.action',
            'login.action'
        ],

```

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?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [June 7, 2021, 6:07am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/2 "2021-06-07T06:07:49Z")

</div>

> [@smj320](#):
>
> 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:

> **[Introduction - mezzio-authorization-acl - Laminas Docs](https://docs.mezzio.dev/mezzio-authorization-acl/v1/intro/#configure-an-acl-system)**
>
> ACL permission adapter for mezzio-authorization.

The you can copy and modify the factory:

> <https://github.com/mezzio/mezzio-authorization-acl/blob/57c194c04086be4785608ce24bed4cd17605bf25/src/LaminasAclFactory.php#L16>

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

> <https://github.com/laminas/laminas-navigation/pull/19>
>
> | Q | A
> |-------------- | ------
> | New Feature | yes
> 
> \### De…scription
> 
> The delegator allows the setting of a ACL for navigation helpers by using a registered \`Laminas\\Permissions\\Acl\\AclInterface\` service.
> 
> \### Example of Usage
> 
> \`\`\`php
> 'navigation\_helpers' =\> \[
> 'delegators' =\> \[
> Laminas\\View\\Helper\\Navigation::class =\> \[
> Laminas\\Navigation\\View\\PermissionAclDelegatorFactory::class,
> \],
> \],
> \],
> \`\`\`

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [June 7, 2021, 6:10am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/3 "2021-06-07T06:10:37Z")

</div>

> [@smj320](#):
>
> ```auto
> 'navigation' => [
> 'default' => [
> [
> 'label' => 'HOME',
> 'controller' => 'home',
> 'action' => 'index',
> 'resource' => 'guest',
> ],...
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![smj320](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/smj320/32/914_2.png) [@smj320](https://discourse.laminas.dev/u/smj320)\
**Post date:** [June 7, 2021, 6:30am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/4 "2021-06-07T06:30:30Z")

</div>

Thank you for your suggestion again.

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

---

<div class="post-metadata">

**Author:** ![smj320](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/smj320/32/914_2.png) [@smj320](https://discourse.laminas.dev/u/smj320)\
**Post date:** [June 7, 2021, 6:39am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/5 "2021-06-07T06:39:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smj320](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/smj320/32/914_2.png) [@smj320](https://discourse.laminas.dev/u/smj320)\
**Post date:** [June 7, 2021, 6:41am UTC](https://discourse.laminas.dev/t/where-should-i-define-acl-for-pages/2336/6 "2021-06-07T06:41:18Z")

</div>

Oh, I found a document.  
[https://docs.mezzio.dev/mezzio/v3/why-mezzio/](https://docs.mezzio.dev/mezzio/v3/why-mezzio/)

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…
