zend-expressive-tooling icon indicating copy to clipboard operation
zend-expressive-tooling copied to clipboard

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

Open adamturcsan opened this issue 7 years ago • 3 comments

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/'],
            ],
        ];
    }
}

adamturcsan avatar Mar 05 '18 18:03 adamturcsan

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

adamturcsan avatar Mar 05 '18 18:03 adamturcsan

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.

michalbundyra avatar Mar 12 '18 13:03 michalbundyra

This repository has been closed and moved to mezzio/mezzio-tooling; a new issue has been opened at https://github.com/mezzio/mezzio-tooling/issues/1.

weierophinney avatar Dec 31 '19 21:12 weierophinney