Download the PHP package phantomwatson/cakephp-json-api without Composer

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

json-api plugin for CakePHP 5

json:api

This plugin implements neomerx/json-api as a View class for cakephp3.

JSON API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests.

JSON API is designed to minimize both the number of requests and the amount of data transmitted between clients and servers. This efficiency is achieved without compromising readability, flexibility, or discoverability.

JSON API requires use of the JSON API media type (application/vnd.api+json) for exchanging data.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

Usage

This plugin works by using neomerx/json-api php module at its core, my advice is to read up on the docs before proceeding.

Load the plugin by adding it to your bootstrap.php

or activate it using the cake shell

Then tell your controller to use the JsonApi view

The following view variables can be assigned in your controller

Variable Description
_serialize this holds the actual data to pass to the encoder instance, can be an array of entities, a single entity.
_url the base url of the api endpoint
_entities required A list of entities that are going to be mapped to Schemas
_include an array of hash paths what should be in the included section of the response. [ 'posts.author', 'comments' ]
_fieldsets A hash path of fields should be in the resultset [ 'sites' => ['name'], 'people' => ['first_name'] ]
_meta meta data to add to the document
_links links to add to the document this should be an array of Neomerx\JsonApi\Schema\Link objects.

Example

Schemas

Entities assigned in _entities are mapped to the EntitySchema base class. This class extends Neomerx\JsonApi\Schema\SchemaProvider.

It is recommended that you create a schema class for each entity you defined by extending the EntitySchema class. Example: if you have an entity in Model\Entity\Author then create a schema class in View\Schema\AuthorSchema

Think of the Schema class as a template that represents an Entity.

Because of this it is possible access the current view object along with Request and helpers. can be called inside the schema if you need it.

Schema example

Example App\View\Schema\AuthorSchema.php (maps to App\Model\Entity\Author)

Request handling and routing

This plugin does not handle this for you but can be easily added to your application using cake's RequestHandler component which has support for the json-api Content-Type.

For instance, if you want to automatically decode incoming json-api (application/vnd.api+json) data you can tell RequestHandler to automaticaly handle it.

RESTfull routing can also be achieved by creating resource routes.


All versions of cakephp-json-api with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
cakephp/cakephp Version ^5.0
neomerx/json-api Version ^4.0
ext-json Version *
ext-mbstring 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 phantomwatson/cakephp-json-api contains the following files

Loading the files please wait ....