Download the PHP package czim/laravel-jsonapi without Composer

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

Latest Version on Packagist Build Status Coverage Status

JSON-API Base

Basic application elements for JSON-API projects.

Offers means for quickly scaffolding JSON-API compliance for Laravel applications.

This does NOT provide the means to set up the API or the means for user authorisation.

Disclaimer

This is very much a work in progress at this time. Interface- and other breaking changes may happen.
The old, discontinued version of this project is in the 0.9.5 branch.

Version Compatibility

Laravel Package
5.3 1.3
5.4 to 5.6 1.4
5.7 to 6.0 1.5

Note that version 1.5+ requires PHP 7.1.3+ and czim/laravel-dataobject 2.0+.

Changelog

View the changelog.

Installation

Via Composer

Add the JsonApiServiceProvider to your config/app.php:

Publish the configuration file.

Exceptions

In your App\Exceptions\Handler, change the render() method like so:

This will render exceptions thrown for all JSON-API (and JSON) requests as JSON-API error responses.

Middleware

To enforce correct headers, add the Czim\JsonApi\Http|Middleware\JsonApiHeaders middleware to the middleware group or relevant routes. You can do this by adding it to your App\Http\Kernel class:

Note that this will block access to any consumers of your API that do not conform their HTTP header use to the JSON-API standard.

Documentation

Request Data

Request Query String Data

JSON-API suggests passing in filter and page data using GET parameters, such as:

This package offers tools for accessing this information in a standardized way:

Using the jsonapi_query() global helper function. This returns the singleton instance of Czim\JsonApi\Support\Request\RequestParser.

You can ofcourse also instantiate the request parser yourself to access these methods:

Request Body Data

For PUT and POST requests with JSON-API formatted body content, special FormRequests are provided to validate and access request body data: \Czim\JsonApi\Http\Requests\JsonApiRequest.

For POST requests where id may be omitted while creating a resource, use \Czim\JsonApi\Http\Requests\JsonApiRequest instead.

These classes may be extended and used as any other FormRequest class in Laravel.

There are also a global help functions jsonapi_request() and jsonapi_request_create(), that returns an instance of the relevant request class (and so mimics Laravel's request()).

Using this approach guarantees that requests are valid JSON-API by validating the input against a JSON Schema.

The request data tree for a single-resource request:

Request Data: Single Resource

For more information on the data object tree, see the Data classes.

Encoding

This package offers an encoder to generate valid JSON-API output for variable input content.

With some minor setup, it is possible to generate JSON output according to JSON-API specs for Eloquent models and errors.

Eloquent models, single, collected or paginated, will be serialized as JSON-API resources.

More information on encoding and configuring resources.

Custom Encoding & Transformation

To use your own transformers for specific class FQNs for the content to be encoded, map them in the jsonapi.transform.map configuration key:

This mapping will return the first-matched for content using is_a() checks. More specific matches should be higher in the list.

As a last resort, you can always extend and/or rebind the Czim\JsonApi\Encoder\Factories\TransformerFactory to provide your own transformers based on given content type.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-jsonapi with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.3
czim/laravel-dataobject Version ^2.0
myclabs/php-enum Version ^1.5
doctrine/dbal Version ^2.5
justinrainbow/json-schema Version ^5.2
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 czim/laravel-jsonapi contains the following files

Loading the files please wait ....