xrow / rest-bundle
CRM接口的REST包
Requires
README
这是一个为第三方应用程序创建API的包。API数据来自您喜欢的CRM(salesforce、navision等)。
安装
- 在您的CRM包中创建一个类并实现CRMPluginInterface。以下是默认的CRM插件类。将您的CRM插件类的路径添加到您的app/config/config.yml中
# app/config/config.yml xrow_rest: plugins: crmclass: path\toYour\CRMPluginClass
- 编辑您的ezpublish/config/config.yml。添加以下配置
# app/config/config.yml assetic: ... assets: ... xrowrest_js: inputs: - %kernel.root_dir%/../vendor/xrow/rest-bundle/Resources/public/js/xrowrest.js output: js/xrowrest.js doctrine: orm: auto_mapping: true
2.1 选择OAuth2包之一:FOSOAuthServerBundle(不包含OpenID Connect)或oauth2-server-bundle(包含OpenID Connect)
2.1.1 对于FOSOAuthServerBundle(https://github.com/FriendsOfSymfony/FOSOAuthServerBundle) ```yml # app/config/config.yml
fos_oauth_server:
db_driver: orm
client_class: xrow\restBundle\Entity\Client
access_token_class: xrow\restBundle\Entity\AccessToken
auth_code_class: xrow\restBundle\Entity\AuthCode
refresh_token_class: xrow\restBundle\Entity\RefreshToken
service:
user_provider: xrowsso.platform.user.provider
storage: xrow_oauth_server.storage
options:
supported_scopes: user
2.1.2 对于oauth2-server-bundle(https://github.com/bshaffer/oauth2-server-bundle) ```yml # app/config/service.yml
services:
oauth2.user_provider:
class: xrow\restBundle\Provider\OAuth2UserProvider
arguments:
- "@service_container"
- "@doctrine.orm.entity_manager"
- "@security.encoder_factory"
oauth2.openid.storage.authorization_code:
class: xrow\restBundle\Storage\OAuth2Memory
arguments:
- {client_credentials: {%oauth2.client_id%: {client_secret: %oauth2.client_secret%}}, keys: {%oauth2.client_id%: {public_key: %oauth2.public_key%, private_key: %oauth2.private_key%}}}
oauth2.openid.grant_type.authorization_code:
class: OAuth2\OpenID\GrantType\AuthorizationCode
arguments:
- "@oauth2.openid.storage.authorization_code"
oauth2.grant_type.user_credentials:
class: xrow\restBundle\GrantType\OAuth2UserCredentials
arguments:
- "@oauth2.storage.user_credentials"
- "@service_container"
oauth2.server:
class: "%oauth2.server.class%"
arguments:
- ["@oauth2.storage.client_credentials", "@oauth2.storage.access_token", "@oauth2.openid.storage.authorization_code", "@oauth2.storage.user_credentials", "@oauth2.storage.refresh_token", "@oauth2.storage.scope"]
- {refresh_token_lifetime: 15552000, use_openid_connect: true, issuer: %oauth_baseurl%, use_jwt_access_tokens: true, always_issue_new_refresh_token: true}
- {authorization_code: "@oauth2.openid.grant_type.authorization_code", refresh_token: "@oauth2.grant_type.refresh_token", user_credentials: "@oauth2.grant_type.user_credentials"}
```yml
# app/config/parameters.yml
parameters:
oauth2.grant_type.user_credentials.class: xrow\restBundle\GrantType\UserCredentials
oauth2.storage.user_credentials.class: xrow\restBundle\Storage\UserCredentials
- 设置您应用程序的app/config/routing.yml中的正确路由
3.1 对于oauth2-server-bundle(https://github.com/bshaffer/oauth2-server-bundle) ```yml # app/config/routing.yml
xrow_rest_api:
resource: "@xrowRestBundle/Controller/ApiController.php"
type: annotation
prefix: /xrowapi/v1
3.2 对于oauth2-server-bundle(https://github.com/bshaffer/oauth2-server-bundle) ```yml # app/config/routing.yml
xrow_rest_apiV2:
resource: "@xrowRestBundle/Controller/ApiControllerV2.php"
type: annotation
prefix: /xrowapi/v2
3.3 如果您想同时使用这两个包
- 将page_head_script.html.twig添加到HTML的head标签中,将page_footer_script.html.twig添加到您的页脚中(!!非常重要:在加载标签之后)
{% block footer %} {% include 'wuvaboshopBundle::page_footer_script.html.twig' %} {% endblock %}
许可证
此包位于MIT许可证之下。请参阅包中的完整许可证。
开发
请参阅开发者的注意事项