Download the PHP package garbetjie/laravel-jsonapi without Composer

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

Laravel JSON:API

Yet another Laravel package that helps you get up and running with JSON:API.

The idea behind this package is to make it as easy as possible to easily get up & running with JSON:API whilst making use of Laravel's Resource.

Build status PHP from Packagist

Table of Contents

Installation

composer require garbetjie/laravel-jsonapi

Basic Usage

In order to generate JSON:API resources with this package, simply return an instance of Garbetjie\Laravel\JsonApi\JsonApiResource from your controller method.

This can be done through creating your own resources that extend JsonApiResource, or through creating a new instance of JsonApiResource directly, and passing in a value that can be converted to a resource (see the following sections on how to do this).

Using JsonApiResourceInterface

When implementing Garbetjie\Laravel\JsonApi\JsonApiResourceInterface, the object that is implementing the interface is directly responsible for representing itself as a JSON:API resource. This means that any object can be used to represent a JSON:API resource.

The easiest way of doing this is ensuring that an instance of an Eloquent Resource implements this interface, as there are a number of helper methods available that make it easier to work with Eloquent models.

Resource definition

Usage

Using ConvertibleToJsonApiResourceInterface

When implementing Garbetjie\Laravel\JsonApi\ConvertibleToJsonApiResourceInterface, you are essentially delegating the implementation of the resource conversion to a different object (one that would typically implement the JsonApiResourceInterface interface).

This is especially useful for your Model instances, where you wouldn't want to implement the JsonApiResourceInterface interface directly, but you still want your models to be able to be represented as JSON:API resources.

Building on the previous example, an example is provided below:

Definition

Using Collections

Working with collections of resources is not much different to working with a single resource. Instead of creating a new instance of your resource, simply make use of the ::collection() static method, as shown below.

All items in the collection provided need to implement either JsonApiResourceInterface or ConvertibleToJsonApiResourceInterface in order to be present in the output.

Changelog


All versions of laravel-jsonapi with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^7.4 || ^8.0
laravel/framework Version ^6.0 || ^7.0 || ^8.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 garbetjie/laravel-jsonapi contains the following files

Loading the files please wait ....