Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify documentation for MVC users. #111

Open
brian-n-millar opened this issue May 8, 2023 · 4 comments
Open

Clarify documentation for MVC users. #111

brian-n-millar opened this issue May 8, 2023 · 4 comments
Labels
Documentation Improvements or additions to documentation Enhancement

Comments

@brian-n-millar
Copy link

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.

@froschdesign froschdesign added the Documentation Improvements or additions to documentation label May 8, 2023
@boesing
Copy link
Member

boesing commented May 8, 2023

Good finding, this is indeed too specific for mezzio projects.

Could be something like:

return [
    '<container config identifier>' => [
        'factories' => [
            MyNamespace\Command\MyCommand::class => MyNamespace\Command\MyCommandFactory::class,
        ],
    ],
];

Plus an addition below like:

> ### Container Config Identifier
>
> - for **Laminas MVC** projects, this has to be `service_manager`
> - for **Mezzio** projects, this has to be `dependencies`

Would you mind creating a PR for this? I'd be happy to merge that.

@brian-n-millar
Copy link
Author

Thank you, I've made a PR using your suggested wording. PR #112

@brian-n-millar
Copy link
Author

brian-n-millar commented May 8, 2023

Looks like I caused linting errors, sorry about that.

Update: fixed.

@froschdesign
Copy link
Member

@brian-n-millar
This is an important hint, so thanks for opening this issue report! 👍🏻

Unfortunately, the entire page is a horror for me, so I will completely rework it. There needs to be a clear separation of explanations and the confusion needs to be resolved.

See also: #112 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants