mezzio / mezzio-tooling

Migration and development tooling for Mezzio
https://docs.mezzio.dev/mezzio/
BSD 3-Clause "New" or "Revised" License
16 stars 11 forks source link

[Feature Request] Add new option to module:create: --namespace=NAMESPACE #1

Closed weierophinney closed 3 years ago

weierophinney commented 4 years ago

Would be nice to have this feature to work with arbitrary namespacing for more complex projects.

Something like

composer expressive module:create --namespace=Vendor\Project ModuleName

Resulting with a module in the default src folder with a folder name ModuleName and a namespace Vendor\Project\ModuleName and a ConfigProvider like the following:

<?php

declare(strict_types=1);

namespace Vendor\Project\ModuleName;

/**
 * The configuration provider for the ModuleName module
 *
 * @see https://docs.zendframework.com/zend-component-installer/
 */
class ConfigProvider
{
    /**
     * Returns the configuration array
     *
     * To add a bit of a structure, each section is defined in a separate
     * method which returns an array with its configuration.
     */
    public function __invoke() : array
    {
        return [
            'dependencies' => $this->getDependencies(),
            'templates'    => $this->getTemplates(),
        ];
    }

    /**
     * Returns the container dependencies
     */
    public function getDependencies() : array
    {
        return [
            'invokables' => [
            ],
            'factories'  => [
            ],
        ];
    }

    /**
     * Returns the templates configuration
     */
    public function getTemplates() : array
    {
        return [
            'paths' => [
                'modulename'    => [__DIR__ . '/../templates/'],
            ],
        ];
    }
}

Originally posted by @adamturcsan at https://github.com/zendframework/zend-expressive-tooling/issues/66

weierophinney commented 4 years ago

Removed -n from title because it is already used for --no-interaction


Originally posted by @adamturcsan at https://github.com/zendframework/zend-expressive-tooling/issues/66#issuecomment-370514426

weierophinney commented 4 years ago

It will requires also changes in zf-composer-autoloading, because create command also register the module in composer and to do that correctly we need to know the namespace of the module.


Originally posted by @michalbundyra at https://github.com/zendframework/zend-expressive-tooling/issues/66#issuecomment-372304223

dgoosens commented 3 years ago

hi @weierophinney

Funny... was just trying to achieve this with the current tools. Is this still relevant for mezzio ?

Pretty sure I should be able to manage if that's any help...

dGo

weierophinney commented 3 years ago

@dgoosens Go for it! And yes, still relevant.

Bonus points if you convert tooling to laminas-cli first. :)

dgoosens commented 3 years ago

hi @weierophinney

Bonus points if you convert tooling to laminas-cli first. :)

Do you mean you'd want this mezzio dedicated toolkit to be based on https://github.com/laminas/laminas-cli ?

weierophinney commented 3 years ago

Yes!

You can likely accomplish it in a BC way by first adding laminas-cli config, and updating the README and docs to detail using the laminas <command names> usage. From there, we can later do a v2 release that removes the mezzio binary.

dgoosens commented 3 years ago

Wow...
That's a little more ambitious than just adding a new option to one of the commands... lol

But I definitely like a challenge and the sideproject I'm currently working on is almost done...
So why not
I'll give it a shot

weierophinney commented 3 years ago

Just FYI, the 2.0.x branch is refactored to be a laminas-cli command provider, if you want to work on this. I have a couple more feature requests for the 2.0.0 milestone, and may come back to this if you haven't provided a patch by then.

weierophinney commented 3 years ago

Resolved with #15