Download the PHP package gzhpackages/laravel-json-api without Composer

On this page you can find all versions of the php package gzhpackages/laravel-json-api. 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 laravel-json-api

laravel-json-api

主要是为了统一前后端 restful api 的返回格式标准,按照 https://jsonapi.org 定义返回指定的数据格式。

最好结合前端库 json-api-fetch 一起使用。

安装

从composer安装

添加service provider

in laravel:

config/app.php 中的 providers 添加

in lumen:

bootstrap/app.php 中添加

发布配置

php artisan vendor:publish --provider "GzhPackages\JsonApi\Providers\LaravelServiceProvider"

使用

Controller

添加一个 trait 给response,ApiHelper包含了4个常用的返回值和status code类型。

分别为 content, noContent, created, accepted

Exception

1、重写 app/Exceptions/Handler.phprender方法

2、命令行创建一个新的 Exception 类

3、根据标准修改 http 状态码

4、在 config/errors.php 中配置错误详情

在字段detail中,可以用大括号 {} 占位符

5、抛出自定义异常

第二个参数为 detail 占位符替换的对象,如果自定义的detail中无占位符,第二个参数可为空

自定义meta信息:


All versions of laravel-json-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
illuminate/config Version ~5.0|~6.0
illuminate/http Version ^5.1|^6
illuminate/support Version ~5.0|~6.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 gzhpackages/laravel-json-api contains the following files

Loading the files please wait ....