Download the PHP package pxc/json-api-client without Composer

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

{ json:api } Client

PHP from Packagist Latest Version on Packagist Build Status Scrutinizer Coverage Scrutinizer Code Quality Made by PrimeXConnect

A PHP package for mapping remote {json:api} resources to Eloquent like models and collections.

A copy of json-api-client

@todo this documentation needs to be updated.

Upgrade from 1.0.x to 1.2.x

The dependency swisnl/json-api-client has been upgraded from '0.10.x' to '0.20.x', supporting Lumen 5.8. In your ServiceProvider

Installation

N.B. Make sure you have installed a HTTP Client before you install this package or install one at the same time e.g. composer require swisnl/json-api-client php-http/guzzle6-adapter.

HTTP Client

We are decoupled from any HTTP messaging client with the help of PHP-HTTP. This requires another package providing php-http/client-implementation. To use Guzzle 6, for example, simply require php-http/guzzle6-adapter:

Laravel Service Provider

If you are using Laravel < 5.5 or have disabled package auto discover, you must add the service provider to your config/app.php file:

Getting started

You can simply require the client as a dependency and use it in your class. This allows you to, for example, make a repository that uses the DocumentClient:

Configuration

The following is the default configuration provided by this package:

Publish Configuration

If you would like to make changes to the default configuration, publish and edit the configuration file:

Clients

This package offers two clients; DocumentClient and Client.

DocumentClient

This is the client that you would generally use. Per the JSON API spec, all requests and responses are documents. Therefore, this client always expects a \Swis\JsonApi\Client\Interfaces\DocumentInterface as input when posting data and always returns this same interface. This can be a plain Document when there is no data, an ItemDocument for an item, a CollectionDocument for a collection or an InvalidResponseDocument when the server responds with a non 2xx response.

The DocumentClient follows the following steps internally:

  1. Send the request using your HTTP client;
  2. Use art4/json-api-client to parse and validate the response;
  3. Create the correct document instance;
  4. Hydrate every item by using the item model registered with the TypeMapper or a \Swis\JsonApi\Client\Item as fallback;
  5. Hydrate all relationships;
  6. Add meta data to the document such as errors, links and meta.

Client

This client is a more low level client and can be used, for example, for posting binary data such as images. It can take everything your request factory takes as input data and returns the 'raw' \Psr\Http\Message\ResponseInterface wrapped in a \Swis\JsonApi\Client\Response. It does not parse or validate the response or hydrate items!

Items

By default, all items are an instance of \Swis\JsonApi\Client\Item. The Item extends jenssegers/model, which provides a Laravel Eloquent-like base class. Please see it's documentation about the features it provides. You can define your own models by extending \Swis\JsonApi\Client\Item or by implementing the \Swis\JsonApi\Client\Interfaces\ItemInterface yourself. This can be useful if you want to define, for example, hidden attributes, casts or get/set mutators. If you use custom models, you must register them with the TypeMapper.

Relations

On top of jenssegers/model, this package has implemented Laravel Eloquent-like relations. These relations provide a fluent interface to retrieve the related items. There are currently four relations available:

Please see the following example about defining the relationships:

Collections

This package uses Laravel Collections as a wrapper for item arrays.

TypeMapper

All custom models must be registered with the TypeMapper. This TypeMapper maps, as the name suggests, JSON API types to custom item models.

Mapping types

You can manually register items with the \Swis\JsonApi\Client\TypeMapper or use the supplied \Swis\JsonApi\Client\Providers\TypeMapperServiceProvider:

Service Provider

The \Swis\JsonApi\Client\Providers\ServiceProvider registers the TypeMapper, JsonApi\Parser and both clients; Client and DocumentClient. Each section can be overwritten to allow extended customization.

Bind TypeMapper

The service provider registers the TypeMapper as a singleton so your entire application has the same mappings available.

Bind Clients

The service provider registers the Client and DocumentClient to your application. By default it uses php-http/discovery to find a HTTP client and message factory. You can specify your own message factory by overwriting the getMessageFactory() method and your own HTTP client by overwriting the getHttpClient() method. The first should return a message factory and the latter should return a HTTP client, both implementing HTTPlug. These methods are the perfect place to add extra options to your HTTP client or register a mock HTTP client for your tests:

N.B. This example uses our swisnl/php-http-fixture-client when in testing environment. This package allows you to easily mock requests with static fixtures. Definitely worth a try!

If you register your own service provider and use package auto discover, don't forget to exclude this package in your package.json:

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

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

SWIS

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.


All versions of json-api-client with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
swisnl/json-api-client Version ^0.20.0
php-http/message Version ^1.7
php-http/client-implementation Version ^1.0
php-http/discovery Version ^1.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 pxc/json-api-client contains the following files

Loading the files please wait ....