ongr/api-bundle

ONGR平台API包。

安装次数: 11,831

依赖项: 2

建议者: 0

安全性: 0

星标: 8

关注者: 19

分支: 9

开放问题: 5

类型:symfony-bundle

v1.0.0 2016-04-06 20:44 UTC

This package is auto-updated.

Last update: 2024-08-25 06:02:51 UTC


README

Api Bundle 允许快速设置RESTful API,以简化远程客户端对Elasticsearch数据的访问。

Build Status

文档

该文档的源存储在此包的 Resources/doc/ 文件夹中。

阅读API Bundle文档

设置包

此示例假设您已经配置了Elasticsearch包。如果您还没有,请参考以下快速设置指南

步骤 1:安装

Api包使用 Composer 安装。

composer require ongr/api-bundle "~1.0"

步骤 2:在 AppKernel 中启用包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
        new ONGR\ApiBundle\ONGRApiBundle(),
    );
}

API Bundle 需要 JMS Serializer 来处理JSON和XML

步骤 3:添加配置

将Api包的最小配置添加到 config.yml

#app/config/config.yml

ongr_api:
    default_encoding: json
        versions:
            v3:
                endpoints:
                    product:
                        repository: es.manager.default.product

上述示例展示了最小配置。要了解更多信息,请参阅配置页面

添加路由

#app/config/routing.yml

ongr_api_routing:
    resource: @ONGRApiBundle/Resources/config/routing.yml
    prefix: /api

您可以根据需要指定前缀,例如 api 只是示例。

步骤 4:完成

它已经准备好使用。API Bundle将根据您的配置生成新的URL端点,根据前面的配置,您将拥有:<yourdomain.com>/api/v3/product

下一步是什么?

前往 配置页面 了解如何充分利用您的API,或查看 基本使用示例

许可证

此包受MIT许可证的保护。请参阅包中的完整许可证LICENSE 文件。