hch / normalizedrestapi-bundle
用于标准化 Rest API 返回结果的包
dev-develop
2016-10-29 23:23 UTC
Requires
- php: >=5.3.2
- hch/normalizedrestapi-bundle: dev-master
- symfony/console: ~2.0
- symfony/framework-bundle: ~2.0
- symfony/serializer: ~2.0
This package is not auto-updated.
Last update: 2024-09-28 19:42:06 UTC
README
用于标准化 Rest API 返回结果的包
安装
运行 composer require hch/normalizedrestapi-bundle=dev-master
创建 erros_code.ini 文件:php app/console app:create-error-code
基本用法
该包可以像这样简单地使用
<?php
use HCH\NormalizedRestApiBundle\ApiException\ApiException;
use HCH\NormalizedRestApiBundle\ApiResponse\ApiResponse;
public function getProductAction(Product $product) {
if(!$product){
throw new ApiException(404);
}
return new ApiResponse(array('Product' => $product));
}