paneedesign/api-bundle
最新稳定版本:v4.0.5
Composer 安装命令:
composer require paneedesign/api-bundle
包简介
Api management for Symfony3 projects.
README 文档
README
Api management for Symfony3 projects.
Installation
Step 1: Download the Bundle
Pane&Design repository is private so, add to composer.json this vcs
"repositories": [ ... { "type" : "vcs", "url" : "git@bitbucket.org:paneedesign/api-bundle.git" } ], ... "require": { ... "paneedesign/api-bundle": "^3.0" }
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require "paneedesign/api-bundle"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new \FOS\OAuthServerBundle\FOSOAuthServerBundle(), new \FOS\RestBundle\FOSRestBundle(), new \JMS\SerializerBundle\JMSSerializerBundle(), new \PaneeDesign\ApiBundle\PedApiBundle(), ); // ... if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { // ... $bundles[] = new \Nelmio\ApiDocBundle\NelmioApiDocBundle(); } } // ... }
Step 3: Configurations
Add parameters
// app/config/parameters.yml.dist
parameters:
...
api_server_host: 'https://api.paneedesign.com'
api_type: oauth2
api_client_id: ~
api_client_secret: ~
api_user_class: PaneeDesign\UserBundle\Entity\User
Add configuration
// app/config/config.yml imports: - { resource: "@PedApiBundle/Resources/config/config.yml" } ...
// app/config/config_dev.yml imports: - { resource: "@PedApiBundle/Resources/config/custom/nelmio_api_doc.yml" } ...
// app/config/routing.yml ped_api: resource: '@PedApiBundle/Resources/config/routing.yml' prefix: / ...
Implement API
// app/config/custom/api.yml public_v1: type: rest prefix: /v1 resource: "@PedApiBundle/Controller/Api/ApiPublicController.php" name_prefix: api_1_ ...
Generate client
php bin/console fos:oauth-server:create-client --redirect-uri="https://api.paneedesign.com/authorize" --grant-type="https://api.paneedesign.com/oauth/v2/api_key" --grant-type="password" --grant-type="refresh_token"
Upgrade from 2.x to 3.x
- rename getApiKeyAccessToken in getOAuthToken
- change signature of
throwRefreshTokenJsonExceptionfromprotected function throwRefreshTokenJsonException(JsonException $jsonException, $expiredAt)toprotected function throwRefreshTokenJsonException(\OAuth2\OAuth2ServerException $oAuthException) - change signature of
refreshTokenResponsefromprotected function refreshTokenResponse(User $user, $accessToken)toprotected function refreshTokenResponse(User $user, array $oAuthToken) - remove
api_access_token_expire_atandapi_refresh_token_expire_atfrom parameters - add
api_client_idandapi_client_secretto parameters
统计信息
- 总下载量: 3.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2019-11-07