Skip to content

Clarify documentation for MVC users. #111

@brian-n-millar

Description

@brian-n-millar

Feature Request

Clarify documentation for MVC users.

Q A
New Feature yes
RFC no
BC Break no

Summary

I was migrating a Zend Framework 3 application to Laminas and hence from zend-console to laminas-cli.
I read the following page:
https://docs.laminas.dev/laminas-cli/intro/

I find step 3 is confusing:

// config/autoload/dependencies.global.php:
return [
    'dependencies' => [
        'factories' => [
            MyNamespace\Command\MyCommand::class => MyNamespace\Command\MyCommandFactory::class,
        ],
    ],
];

I spent a good while trying to get this to work and could not, it was only by reading the other stuff further down about ConfigProvider:

namespace MyNamespace;

class Module
{
    public function getConfig() : array
    {
        $configProvider = new ConfigProvider();

        return [
            'laminas-cli' => $configProvider->getCliConfig(),
            'service_manager' => $configProvider->getDependencyConfig(),
        ];
    }
}

That I then realized that dependencies should be service_manager for MVC applications and I got the first code working by making it be like:

return [
    'service_manager' => [
        'factories' => [
            MyNamespace\Command\MyCommand::class => MyNamespace\Command\MyCommandFactory::class,
        ],
    ],
];

Maybe this is obvious to some but I think it would help MVC users to point this out clearly in step 3 as it took me some time to realize why it wasn't working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions