Php blueprint closure vs array[]

Hi,

I want to find out why my closure (function()-return) approach in my php-blueprints do not work! When I use this approach my blueprint is not loaded but the default page blueprint is used… It’s only when I use an array type of return my blueprint (page) is used ie visible. Just want to understand why!

Thanks in advance!

Non working blueprint:

<?php

// Load the helper functions from our plugin
require_once kirby()->plugin('padeltime/mymanager')->root() . '/helpers.php';

return function ($page) {
    return [
        'title'   => 'Clubs Section',
        'icon'    => 'archive',
        'columns' => [
            'main' => [
                'width' => '1/1',
                'sections' => [
                    'clublist' => [
                        'headline' => 'Clubs',
                        'type'     => 'pages',
                        'template' => 'club',
                        'info'     => "Players: {{ page.children.filterBy('template', 'player').count }} | Lessons: {{ page.children.filterBy('template', 'lesson').count }}",
                        'query'    => 'page.getVisibleClubs',
                        'create'   => checkPermission('create', 'club')
                    ]
                ]
            ]
        ]
    ];
};

Working php-bleuprint version:

<?php

// Load the helper functions from our plugin
require_once kirby()->plugin('padeltime/mymanager')->root() . '/helpers.php';

return [
    'title'   => 'Clubs Section',
    'icon'    => 'archive',
    'columns' => [
        'main' => [
            'width' => '1/1',
            'sections' => [
                'clublist' => [
                    'headline' => 'Clubs',
                    'type'     => 'pages',
                    'template' => 'club',
                    'info'     => "Players: {{ page.children.filterBy('template', 'player').count }} | Lessons: {{ page.children.filterBy('template', 'lesson').count }}",
                    'query'    => 'page.getVisibleClubs',
                    'create'   => checkPermission('create', 'club')
                ]
            ]
        ]
    ]
];

Why do you think you could return a PHP based blueprint as a closure and not as an array (which would mirror the nested YAML)?

Nico, thanks for the question and fast response…
It triggered me to look into the docs once again… and it seems I’m just doing things right. There is no use in returning a blueprint as a closure…

I found what the issue is here… since i’m getting deeper into Kirby cms with the help of AI, gemini to be more specific (which covers many of my questions), this also brings confusion sometimes…
Gemini sometimes (as also in this case) proposes solutions which are not suitable or even wrong, like proposing to return a closure…

Rest me to excuse myself for bothering you!

Regards,

Mark

have you tried adding the kirby docs via mcp to your AI workflow? it might reduce such hallucinations. GetKirby Docs at context7 MCP