Mezzio routes autowiring not working with delegators in a module

Hi, I’m trying to autowire routes as suggested in the docs here.

My config provider class is as follows.

class ConfigProvider
{
    public function __invoke(): array
    {
        return [
            'dependencies' => $this->getDependencies(),
            'templates'    => $this->getTemplates(),
        ];
    }

    public function getDependencies(): array
    {
        return [
            'invokables' => [
                Handler\PingHandler::class => Handler\PingHandler::class,
            ],
            'factories'  => [
                Handler\HomePageHandler::class => Handler\HomePageHandlerFactory::class,
            ],
            'delegators' => [
                \Mezzio\Application::class => [
                    \LrphptMenu\Factory\PipelineAndRoutesDelegator::class,
                ],
            ],
        ];
    }

    public function getTemplates(): array
    {
        return [
            'paths' => [
                'lrphpt-menu'    => [__DIR__ . '/../templates/'],
            ],
        ];
    }
}

Code as mentioned in PipelineAndRoutesDelegator.

class PipelineAndRoutesDelegator
{
    public function __invoke(
        ContainerInterface $container,
        string $serviceName,
        callable $callback
    ) : Application {
        /** @var $app Application */
        $app = $callback();

        // Setup routes:
        $app->get('/lrphpt-menu', \LrphptMenu\Handler\HomePageHandler::class, 'lrphpt-menu');

        return $app;
    }
}

Thanks!

Sorry for my beginner’s mistake. I’ve not added the module in config/config.php. A massive difference between MVC to Mezzio.

$aggregator = new ConfigAggregator([
\LrphptMenu\ConfigProvider::class,
/* rest of the world */
]);

Apologies!

Be sure to read and fully understand the implications of that approach.

Hi @Tyrsson, thanks for sharing the information. But what can I say? As a human, I’m bound to break the law and the commandments. :wink:
I’m only following what the father has prescribed in this link.
Please ask the father why he has prescribed this in this forum. :smile:

In Mezzio it’s a little different when you are providing components via composer. The docs explain why this is the case. It is a different use case when you start delegating it from an installable vs a module at the application level. They are NOT the same use case. Understanding the implications of why they are not the same is important in Mezzio. Especially for your downstream users of this module/component and the implications and effects it will/could have for their applications.

You think you are following what mwop suggested. And in one aspect you are but its not the same use case and in this respect it matters.

Laminas component installer. You will need to consider this in your components composer.json file. Check the docs for the component installer. It covers the relevant information.