alterway/rest-problem-bundle 问题修复 & 功能扩展

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

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

alterway/rest-problem-bundle

Composer 安装命令:

composer require alterway/rest-problem-bundle

包简介

way to respect Problem Details for HTTP APIs RFC (http://tools.ietf.org/html/draft-nottingham-http-problem-03)

README 文档

README

# RestProblemBundle

Bundle to manage Problems in API with Symfony2.

Build Status

This bundle follows the Problem Details for HTTP APIs recommandation.

## Installation

Edit your composer.json:

"require": {
    "alterway/rest-problem-bundle" : "master"
}

And run Composer:

php composer.phar update alterway/rest-problem-bundle

Enable your bundle in your AppKernel.php:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Alterway\Bundle\RestProblemBundle\AwRestProblemBundle(),
    );
}

Usage

use Alterway\Bundle\RestProblemBundle\Response\ProblemResponse;
use Alterway\Bundle\RestProblemBundle\Problem;

public function demoAction(Request $request)
{

    $form = // (...)

    $form->bind($request);
    if (!$form->isValid()) {
        $problem = new Problem\InvalidQueryForm($form);
        return new ProblemResponse($problem, 403);
    }
}

## Usage with annotations

Remember to enable annotations :

sensio_framework_extra:
router:  { annotations: true }
request: { converters: true }
view:    { annotations: true }
cache:   { annotations: true }

And to register the autoloader in your app/autoload.php file:

Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass')); 

This will send an application/api-problem+json header:

use Alterway\Bundle\RestProblemBundle\Response\ProblemResponse;
use Alterway\Bundle\RestProblemBundle\Controller\Annotations\Problem;

/**
* @Problem
*/
public function demoAction(Request $request)
{

    $form = // (...)

    $form->bind($request);
    if (!$form->isValid()) {
        return new Problem\InvalidQueryForm($form);
    }
}

Problem's types

You need to create your own problem types. There are by default the following problems:

  • Problem\InvalidQuery
  • Problem\InvalidQueryForm
  • ...

Todo

Add controllers and route to provide problemType

## Contribute

Install dev dependencies:

php composer.phar update --dev

Run Behat:

./vendor/bin/behat @AwRestProblemBundle

Copyright

Copyright (c) 2013 La Ruche Qui Dit Oui!. See LICENSE for details.

Contributors

  • Lead: Jean-François Lépine (Halleck45)
  • Developer: Antoine Lévêque (gh0stonio)

Sponsors

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 12
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固