terminal42/rokka-io-api-platform-bridge
Composer 安装命令:
composer require terminal42/rokka-io-api-platform-bridge
包简介
Provides collection and item providers, data persisters and more to easily integrate ApiPlatform and rokka.io
README 文档
README
Seamlessly integrates your rokka.io account with ApiPlatform.
Why?
Why would you bridge an API that is already an API? These are the main reasons:
- Using the bundle, you can hide the API key of rokka.io behind your already existing API.
- You can use the same authentication mechanism that already protects your API to also protect rokka.io image handling.
- It automatically updates the Swagger docs of your API based on the docs of rokka.io so it's always up to date.
- It brings a consistent feeling to the developers using your API.
It works by simply bridging all the requests you make to your API to rokka.io by using the same path and enhancing it
with the authorization header for rokka.io. By default it does that using the /rokka bridge endpoint but this can be
configured.
Example: Let's say you want to create a new source image. In rokka.io that would be a POST request to
/sourceimages/{organization}.
So instead of sending a POST request to https://api.rokka.io/sourceimages/{organization} you would send
a POST request to https://myapi.com/rokka/sourceimages/{organization}.
Because you never want to expose the whole API for rokka.io (otherwise one could also modify your account),
the allowed endpoints have to be configured (see Configuration section). Thus you can bridge any endpoint you like.
The cool thing with this concept is that if you wanted to allow some users to modify your account, you can enable this
endpoint and protect it using your authentication mechanisms very easily.
Also, you can omit the whole {organization} part by configuring a default_organization, it will automatically
use this one whenever you request anything.
Installation
-
Use Composer and run
$ composer require terminal42/rokka-io-api-platform-bridgeImportant: This bundle uses HTTPlug to decouple from any specific HTTP client. This means that if you already use one of the available clients, it will simply re-use this one. If you haven't got any client yet, you have to choose one and install these first (or at the same time). E.g. if you want to use
Guzzle, install the bundle like so:$ composer require terminal42/rokka-io-api-platform-bridge php-http/guzzle6-adapter php-http/message -
Configure the rokka.io Symfony Bundle as documented in their docs.
-
Load the bundle in your kernel which is done automatically if you use Symfony Flex, otherwise use
$bundles = [ ... new Terminal42\RokkaApiPlatformBridge\RokkaApiPlatformBridgeBundle(), ];
-
Add the route loader of this bundle to your routing configuration:
# config/routes.yaml (or if you're still on SF 3: app/routing.yml) rokka_api_platform_bridge: resource: . type: rokka_api_platform_bridge
-
Configure this bundle as shown in the
Configurationsection.
Configuration
# config/rokka_api_platform_bridge.yaml rokka_api_platform_bridge: api_key: '' # Required bridge_endpoint: '/images' # Default: '/rokka' default_organization: ~ # Default: null http_client: ~ # Default: null endpoints: - { path: '/sourceimages/{organization}', methods: ['POST'] } - // etc.
Custom Http Client
You can pass a service id via rokka_api_platform_bridge.http_client which must be an instance of the PSR
Http\Client\HttpClient. Thanks to this you can create your own instance that implements logging etc. or even reuse
existing Symfony bundles such as the very popular eightpoints/guzzle-bundle. You only need to wrap the Guzzle
client with the PSR compatible adapter you get using php-http/guzzle6-adapter. You can then configure the Guzzle
service like so:
# config/eight_points_guzzle.yaml eight_points_guzzle: logging: true profiling: true rokka_api_platform_bridge: ~ # config/rokka_api_platform_bridge.yaml rokka_api_platform_bridge: http_client: 'app.my_rokka_api_platform_bridge_service' # config/services.yaml app.my_rokka_api_platform_bridge_service: class: Http\Adapter\Guzzle6\Client arguments: ['@eight_points_guzzle.client.rokka_api_platform_bridge']
Roadmap / Ideas
- Thumbnail endpoint to hide the rokka.io URL?
- Your ideas?
terminal42/rokka-io-api-platform-bridge 适用场景与选型建议
terminal42/rokka-io-api-platform-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 terminal42/rokka-io-api-platform-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 terminal42/rokka-io-api-platform-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-17
