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

On this page you can find all versions of the php package bchalier/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

JsonApi - Laravel Resource

A Lightweight {JSON:API} Resource for Laravel.

example branch parameter codecov

Installation

Config

Path Type Description
describer.nullable bool For describer notation, defined if a value is nullable by default.
describer.date string datetime format For describer notation, defined default date time format.
describer.precision int \ null For describer notation, decimal precision for float value. null for disable rounding.
describer.when-has bool \ string[] For describer notation, Apply automatically whenHas condition on attributes.
relationship.when-included bool Allow to disabled by default the loading of relationship data.

Usage

This package is a specialisation of Laravel's JsonResource class. All the underlying API's are still there, thus in your controller you can still interact with JsonApiResource classes as you would with the base JsonResource class

Request

This package allows the reading and dynamic inclusion of resources that will be requested in the requests via the "include" parameter.
@see {json:api} fetching-includes

Resource attributes will also be filtered according to the "fields" parameter.
@see {json:api} fetching-fields

You can also very simply validate your requests for a given resource via the rules Rules\Includes and Rules\Fields.

Include validation

Rules\Includes will validate the include to exactly match the UserResource schema (determined by the relationships).

Fields validation

Rules\Fields will validate the fields to exactly match the UserResource schema (determined by the attributes and relationships).

Customize validation message

Trans key default
validation.custom.jsonapi.fields.invalid The selected :attribute is invalid.
validation.custom.jsonapi.fields.invalid_fields ":resource" doesn \' t have fields ":fields".
validation.custom.jsonapi.fields.invalid_resource ":resource" doesn \' t exists.
validation.custom.jsonapi.includes.invalid The selected :attribute is invalid.
validation.custom.jsonapi.includes.invalid_includes ":include" doesn \' t have relationship ":relation".

Resource

@see {json:api} resource-type

Implementable methods :

Example:

toType

@see {json:api} resource-type

Returns resource type.

Default returns model class in kebab case : App\Models\MyPost => my-post

toIdentifier

@see {json:api} resource-identifier

Returns resource identifier.

Default returns model id.

toAttributes

@see {json:api} resource-attributes

Returns resource attributes.

Laravel conditional attributes

@see laravel: eloquent-conditional-attributes

Support laravel conditional attributes.

Described attributes

@see described notation

toRelationships

@see {json:api} resources-relationships

Returns resource relationships.

All relationships must be created with ModelResource::relationship. This allows the generation of the schema representing the resource and thus the validation of request includes.

If your relation should have been a collection created via the ::collection(...) method, you can simply use ->asCollection().

If you want the relation data to be loaded only when it is present in the request include, you can use the ->whenIncluded() method.

toRelationships must returns an array, keyed by string, of JsonApiResource or JsonApiCollection.

Laravel conditional relationships

@see laravel: eloquent-conditional-relationships

Support laravel conditional relationships.

Described attributes

@see described notation

Relation links and meta

@see {json:api}: relation-linkage
@see {json:api}: relation-meta

Returns links and meta for a relation.

toLinks

@see {json:api}: resource-linkage

Returns resource links.

toResourceMeta

@see {json:api}: resource-meta
@see {json:api}: document-meta

Returns resource meta.

toMeta

@see {json:api}: document-meta

Returns document meta.

Collection

@see laravel: resource-collection

Collection are implemented in JsonApiCollection.

Usage is the same as laravel collections.

Described notation

Value methods

Method Description
bool Cast to boolean
integer Cast to integer
float Cast to float
string Cast to string
date Cast to date, allow to use custom format
array Cast to array
mixed Don't cast, return as is
enum Get enum value.

Relation methods

Method Description
one For relationship with a single value: HasOne, BelongsTo, ...
many For relationship with many value: HasMany, BelongsToMany, ...

Enum

Method enum allow to get enum value for backed enum or name for unit enum.

According to structure:

The following attributes resource:

Will return:


All versions of laravel-json-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/collections Version ^11.0
illuminate/http Version ^11.0
illuminate/support Version ^11.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 bchalier/laravel-json-api contains the following files

Loading the files please wait ....