### 模块
把 `Application` 模块复制一份为 `Album`
> module/Album
再修改命名空间
```php
namespace Album;
```
**自动加载**
> composer.json
```json
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/",
"Album\\": "module/Album/src/"
}
},
```
更新
```bash
composer dump-autoload
```
**模块配置**
路由规则、模板目录和控制器
> module/Album/config/module.config.php
```php
namespace Album;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'controllers' => [
'factories' => [
Controller\AlbumController::class => InvokableFactory::class,
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
```
全局
> config/modules.config.php
```php
return [
'Zend\Form',
'Zend\Db',
'Zend\Router',
'Zend\Validator',
'Application',
'Album', // <-- 添加这行
];
```