Download the PHP package godruoyi/dingo-api-helper without Composer

On this page you can find all versions of the php package godruoyi/dingo-api-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dingo-api-helper

Dingo api response helper.

StyleCI dingo-api-helper dingo-api-helper dingo-api-helper

说明

默认情况下,Dingo/api 提供的 response 需要配置一大堆信息,包括

1、Adapter 的配置

并且默认的 ArraySerializer 返回格式比较奇怪,如返回资源集合时,ArraySerializer 的返回格式如下:

在最外层包含一层无用 data

2、Transformer 的指定

默认情况下在 controller 在中通过 dingo response 返回数据时,必须指定 Transformer 的位置;

若不指定 Transfoemr 的位置,你将会得到一个参数不匹配的错误。

这显然不是我们想要的结果。我们希望框架能自动处理 Transformer 的位置,也能够手动指定。

3、无法自定义错误码

从上面可以看到,dingo/api 返回的错误响应无法自定义错误码,错误信息里只含有标准的 http 状态码,这显示是不够用的。

虽然他也提供了 errorFormat 配置,但该配置的 code 错误码实际调用的是 $exception->getCode(),在实际工作中并没什么用。

综上,我们开发了一个新的 Package 来解决以上问题,并提供了如

等功能,希望您的喜欢 ❤️❤️❤️

安装

使用

Laravel 版本小于 5.5 时,需要手动注册 Provider。

配置成功后,即可在你的 controller 使用:

默认的 Transformer 文件在 App/Transformers 下,你可通过修改方法的第二个参数指定 transformer 的位置。

可用的方法列表

成功响应方法列表

错误响应方法列表

更多详情请参考 https://learnku.com/docs/dingo-api/2.0.0/Responses/1446

返回格式

返回格式遵循 Restful api 设计规范,具体如下。

Success Response

1、获取单个资源详情(item)

2、获取资源集合(collection)

3、额外的媒体信息(paginator)

Failure Response

禁用预加载

有时候你可能想在 Transformer 中定义一些不存在的 Relation include,如:

由于 fractal 默认开启了预加载机制,你可能会得到一个如下的错误:

可通过禁用 Model 的预加载解决

参考


All versions of dingo-api-helper with dependencies

PHP Build Version
Package Version
Requires illuminate/container Version ^5.7 | ^5.8 | ^5.5 | ^5.6
dingo/api Version ^2.3 | ^2.2 | ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package godruoyi/dingo-api-helper contains the following files

Loading the files please wait ....