auto1-oss/service-api-components-bundle
Composer 安装命令:
composer require auto1-oss/service-api-components-bundle
包简介
Auto1 Common Components for Service API/Client/Handler Bundles
README 文档
README
config.yml
framework: serializer: { enabled: true } property_info: { enabled: true }
Example EP Provider symfony.service declaration:
tag
{ name: 'auto1.api.endpoint_provider', priority: 0 }
services.yml
services: your_app.api.endpoint.provider: class: Auto1\ServiceAPIComponentsBundle\Service\Endpoint\EndpointProviderConfiguration arguments: - '@auto1.api.endpoint.factory' - '@your_app.api.endpoint_configuration.loader' tags: - { name: 'auto1.api.endpoint_provider', priority: 0 } your_app.api.endpoint_configuration.loader: class: Auto1\ServiceAPIComponentsBundle\Service\Endpoint\EndpointsConfigurationLoader arguments: - '%kernel.project_dir%/src/Resources/endpoints.yml'
Super Quick Start:
Only for proof of concept etc.
class YourProvider implements EndpointProviderInterface { public function getEndpoints(): array { return [ new EndpointImmutable( ..., ), ]; } }
services: your_app.api.endpoint.provider: class: YourProvider tags: - { name: 'auto1.api.endpoint_provider', priority: 0 }
Example of EP definition (yaml):
# Auth - method: 'POST' baseUrl: '%wkda.java_api.url%' path: '/v1/auth/oauth/token' requestFormat: 'url' requestClass: 'Auto1\ServiceDTOCollection\Authentication\OAuth\Request\PostRefreshTokenRequest' responseClass: 'Auto1\ServiceDTOCollection\Authentication\OAuth\Response\Token' - method: 'GET' baseUrl: '%wkda.java_api.admin_url%' path: '/v1/auth/user/admin/{userUuid}/roles' requestFormat: 'url' requestClass: 'Auto1\ServiceDTOCollection\Authentication\User\Request\GetUserRolesRequest' responseClass: 'Auto1\ServiceDTOCollection\Authentication\User\Response\UserRoles' # CarLead - method: 'GET' baseUrl: '%wkda.java_api.url%' path: '/v1/carlead/vin/{vin}' requestClass: 'Auto1\ServiceDTOCollection\CarLead\CarLeadRead\Request\GetCarDetailsByVinRequest' responseClass: 'Auto1\ServiceDTOCollection\CarLead\CarLeadRead\Response\CarLead[]'
Alternative:
# Auth refreshToken: method: 'POST' baseUrl: '%wkda.java_api.url%' path: '/v1/auth/oauth/token' requestFormat: 'url' requestClass: 'Auto1\ServiceDTOCollection\Authentication\OAuth\Request\PostRefreshTokenRequest' responseClass: 'Auto1\ServiceDTOCollection\Authentication\OAuth\Response\Token' getUserRoles: method: 'GET' baseUrl: '%wkda.java_api.admin_url%' path: '/v1/auth/user/admin/{userUuid}/roles' requestFormat: 'url' requestClass: 'Auto1\ServiceDTOCollection\Authentication\User\Request\GetUserRolesRequest' responseClass: 'Auto1\ServiceDTOCollection\Authentication\User\Response\UserRoles' # CarLead getCarLeadByVin: method: 'GET' baseUrl: '%wkda.java_api.url%' path: '/v1/carlead/vin/{vin}' requestClass: 'Auto1\ServiceDTOCollection\CarLead\CarLeadRead\Request\GetCarDetailsByVinRequest' responseClass: 'Auto1\ServiceDTOCollection\CarLead\CarLeadRead\Response\CarLead[]'
Example of ServiceRequest implementation:
class GetCarDetailsByVinRequest implements ServiceRequestInterface { private $vin; public function setVin(string $vin): self { $this->vin = $vin; return $this; } public function getVin() { return $this->vin; } }
Url resolution
For altering the default behaviour of Url resolution see UrlResolverCompilerPass and use auto1.api.url_resolver tag together with priority:
# this is a default resolver auto1.api.url_resolver.parameter_aware: class: Auto1\ServiceAPIComponentsBundle\Service\UrlResolver\ParameterAwareUrlResolver arguments: - '@service_container' tags: - { name: 'auto1.api.url_resolver', priority: 0 }
Debug:
To output all registered endpoints:
bin/console auto1.debug.endpoints
auto1-oss/service-api-components-bundle 适用场景与选型建议
auto1-oss/service-api-components-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89.57k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 auto1-oss/service-api-components-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 auto1-oss/service-api-components-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 89.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 18
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-19