Download the PHP package sycho/json-api without Composer

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

PHP JSON-API

Build Status Coverage Status Quality Score Pre Release License

JSON-API responses in PHP.

Works with version 1.0 of the spec.

Install

via Composer:

Usage

Elements

The JSON-API spec describes resource objects as objects containing information about a single resource, and collection objects as objects containing information about many resources. In this package:

Both Resources and Collections are termed as Elements. In conceptually the same way that the JSON-API spec describes, a Resource may have relationships with any number of other Elements (Resource for has-one relationships, Collection for has-many). Similarly, a Collection may contain many Resources.

A JSON-API Document may contain one primary Element. The primary Element will be recursively parsed for relationships with other Elements; these Elements will be added to the Document as included resources.

Sparse Fieldsets

You can specify which fields (attributes and relationships) are to be included on an Element using the fields method. You must provide a multidimensional array organized by resource type:

Serializers

A Serializer is responsible for building attributes and relationships for a certain resource type. Serializers must implement Tobscure\JsonApi\SerializerInterface. An AbstractSerializer is provided with some basic functionality. At a minimum, a serializer must specify its type and provide a method to transform attributes:

By default, a Resource object's id attribute will be set as the id property on the model. A serializer can provide a method to override this:

Relationships

The AbstractSerializer allows you to define a public method for each relationship that exists for a resource. A relationship method should return a Tobscure\JsonApi\Relationship instance.

By default, the AbstractSerializer will convert relationship names from kebab-case and snake_case into a camelCase method name and call that on the serializer. If you wish to customize this behaviour, you may override the getRelationship method:

Meta & Links

The Document, Resource, and Relationship classes allow you to add meta information:

They also allow you to add links in a similar way:

You can also easily add pagination links:

Serializers can provide links and/or meta data as well:

Note: Links and metadata of the resource overrule ones with the same key from the serializer!

Parameters

The Tobscure\JsonApi\Parameters class allows you to easily parse and validate query parameters in accordance with the specification.

getInclude

Get the relationships requested for inclusion. Provide an array of available relationship paths; if anything else is present, an InvalidParameterException will be thrown.

getFields

Get the fields requested for inclusion, keyed by resource type.

getSort

Get the requested sort criteria. Provide an array of available fields that can be sorted by; if anything else is present, an InvalidParameterException will be thrown.

getLimit and getOffset

Get the offset number and the number of resources to display using a page- or offset-based strategy. getLimit accepts an optional maximum. If the calculated offset is below zero, an InvalidParameterException will be thrown.

Error Handling

You can transform caught exceptions into JSON-API error documents using the Tobscure\JsonApi\ErrorHandler class. You must register the appropriate Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface instances.

Contributing

Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated!

Running Tests

License

This code is published under the The MIT License. This means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact.


All versions of json-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
ext-json Version *
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 sycho/json-api contains the following files

Loading the files please wait ....