Module 如何更改默认模块?

Module 如何更改默认模块?,module,zend-framework3,Module,Zend Framework3,我已经安装了ZF3,默认模块为“应用程序”。我想在默认情况下更改其他模块。我该怎么做 编辑I: 我做了一些更改,但不起作用: /config/modules.config.php return [ 'Zend\Router', 'Zend\Validator', 'Test', ]; <?php namespace Test; use Zend\ServiceManager\Factory\InvokableFactory; return [ 'con

我已经安装了ZF3,默认模块为“应用程序”。我想在默认情况下更改其他模块。我该怎么做

编辑I: 我做了一些更改,但不起作用:

/config/modules.config.php

return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];
return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => [
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'test/index/index' => __DIR__ . '/../view/test/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ],        
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];
/module/Test/config/module.config.php

return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];
return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => [
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'test/index/index' => __DIR__ . '/../view/test/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ],        
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];
/module/Test/config/module.config.php

return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];
return [
    'Zend\Router',
    'Zend\Validator',
    'Test',
];
<?php
namespace Test;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],
    ],
    'router' => [
        'routes' => [
            'home' => [
                'type'    => "Literal",
                'options' => [
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => [
                        'controller'    => Controller\IndexController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    // You can place additional routes that match under the
                    // route defined above here.
                ],
            ],
        ],
    ],
    'view_manager' => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => [
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'test/index/index' => __DIR__ . '/../view/test/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ],        
        'template_path_stack' => [
            'Test' => __DIR__ . '/../view',
        ],
    ],
];

您必须执行以下操作:

  • /config/modules.config.php
    中,将
    应用程序
    替换为您的模块名称。不要忘记将
    Zend\Router
    放在要加载的模块列表中,然后再加载模块
  • 在模块中,编写一个
    config/module.config.php
    文件,如
    /module/Application/config/module.config.php
    ,并用模块名称替换
    应用程序
    (尤其是在
    模板映射
    数组中)
  • /composer.json
    部分的
    自动加载
    自动加载开发
    中,用模块名称替换对“应用程序”的引用。然后运行
    composer update
    以更新
    composer/autoload\ux…
    文件
  • 使用
    index.phtml
    404.phtml
    文件将
    view/error
    目录添加到模块文件夹中
  • 在模块文件夹中添加一个
    view\layout\layout.phtml
    文件
小心名称空间!
这应该是可行的。

您必须执行以下操作:

  • /config/modules.config.php
    中,将
    应用程序
    替换为您的模块名称。不要忘记将
    Zend\Router
    放在要加载的模块列表中,然后再加载模块
  • 在模块中,编写一个
    config/module.config.php
    文件,如
    /module/Application/config/module.config.php
    ,并用模块名称替换
    应用程序
    (尤其是在
    模板映射
    数组中)
  • /composer.json
    部分的
    自动加载
    自动加载开发
    中,用模块名称替换对“应用程序”的引用。然后运行
    composer update
    以更新
    composer/autoload\ux…
    文件
  • 使用
    index.phtml
    404.phtml
    文件将
    view/error
    目录添加到模块文件夹中
  • 在模块文件夹中添加一个
    view\layout\layout.phtml
    文件
小心名称空间!
这应该行。

谢谢你的回答,我已经添加了关于我问题的更多信息。我已经详尽地完成了我的回答。告诉我是否适合你。谢谢你的回答,我已经添加了更多关于我的问题的信息。我已经详尽地完成了我的回答。告诉我它是否适合你。