ongr / api-bundle
ONGR平台API包。
v1.0.0
2016-04-06 20:44 UTC
Requires
- php: >=5.5
- jms/serializer-bundle: ~1.0
- ongr/elasticsearch-bundle: ~1.0
- sensio/framework-extra-bundle: ^3.0
- symfony/symfony: ~2.7|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.4
- satooshi/php-coveralls: ~1.0
- squizlabs/php_codesniffer: ~2.0
- symfony/monolog-bundle: ~2.0
This package is auto-updated.
Last update: 2024-08-25 06:02:51 UTC
README
Api Bundle 允许快速设置RESTful API,以简化远程客户端对Elasticsearch数据的访问。
文档
该文档的源存储在此包的 Resources/doc/
文件夹中。
设置包
此示例假设您已经配置了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 文件。