bartlomiejbeta/api-scope-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bartlomiejbeta/api-scope-bundle

Composer 安装命令:

composer require bartlomiejbeta/api-scope-bundle

包简介

Simple API query string scope recognizer

README 文档

README

This Symfony bundle aims to provide simple serialization group recognize from query string (with basic security check if you need it).

Build Status

Installation

1. Install via composer:
composer require bartlomiejbeta/api-scope-bundle
2. Register bundle in AppKernel:
public function registerBundles()
{
    $bundles = array(
        // ...
		new BartB\APIScopeBundle\APIScopeBundle(),
    );
}
3. Configure in config.yml:
api_scope:
    scopes:
        api.get_item: #route name
            always_included: #will be always included to scopes bag
                - 'first_always_included_group'
                - 'second_always_included_group'
            supported_key_map:
                external1: { internal_name: 'scope.internal_name1'} #if `external1` will be in the query string than `scope.internal_name1` will be in the scopes bag
                external2:
                    internal_name: 'scope.internal_name2'
                    security: 'can-add-external2-scope' # security voter (check symfony security voter) attribution name (to check if scope can be applied)

Usage

1. Simple

/**
* @ScopeConverter()
* @Rest\Route("/api/item", name="api.get_item")
*/
public function getCarCollection(Request $request, ScopeCollection $scopeCollection): Response
{
	$view = $this->view($scopeCollection, Response::HTTP_OK);
	
	$scopesFromQueryString = $scopeCollection->getScopes()
	
	return $this->handleView($view);
}
example request:
.../api/item?with[]=external1
example response:
{"scopes":["first_always_included_group","second_always_included_group","scope.internal_name1"]}

2. Configured

/**
* @ScopeConverter(value="scopes",queryString="scope")
* @Rest\Route("/api/item", name="api.get_item")
*/
public function getCarCollection(Request $request, ScopeCollection $scopes): Response
{
	$view = $this->view($scope,Response::HTTP_OK);
		
	scopesFromQueryString = $scopeCollection->getScopes()
		
	return $this->handleView($view);
}
example request:
.../api/item?scope[]=external1&scope[]=external2
example response:
{"scopes":["first_always_included_group","second_always_included_group","scope.internal_name1","scope.internal_name2"]}

统计信息

  • 总下载量: 7.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固