final-gene/rest-api-entry-point-module

提供了一个REST资源,它表示API的入口点。

1.1.1 2016-04-02 12:36 UTC

This package is auto-updated.

Last update: 2024-09-10 22:39:53 UTC


README

提供了一个REST资源,它表示API的入口点。

安装

当Composer路径可用后,您即可安装此模块。

composer require final-gene/rest-api-entry-point-module

然后,将FinalGene\RestApiEntryPointModule添加到您的应用程序配置文件中。

配置

您现在可以配置一个虚拟入口点控制器(例如 FinalGene\RestApiEntryPointModule\EntryPointController),它将实际将FinalGene\RestApiEntryPointModule\Resource\EntryPointResource映射为监听器。

以下是一个可能的REST配置示例

return [
    'zf-rest' => [
        'FinalGene\RestApiEntryPointModule\EntryPointController' => [
            'listener' => FinalGene\RestApiEntryPointModule\Resource\EntryPointResource::class,
            'route_name' => 'api/rest',
            'collection_name' => null,
            'collection_http_methods' => [
                'GET',
            ],
        ],
    ],
];

生成的路由配置可能如下所示

return [
    'router' => [
        'routes' => [
            'api' => [
                'type' => 'literal',
                'options' => [
                    'route' => '/api',
                'child_routes' => [
                    'rest' => [
                        'type' => 'literal',
                        'options' => [
                            'route' => '/rest',
                            'defaults' => [
                                'controller' => 'FinalGene\RestApiEntryPointModule\EntryPointController',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
];