Download the PHP package yzen.dev/laravel-json-api-response without Composer

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

JsonApiResponse

Packagist Version GitHub Workflow Status Coverage License Packagist Downloads Packagist Downloads PHPStan

JsonApiResponse helps you build JSON:API-compatible response payloads with small responder classes.

The package is framework-light: the responder logic itself works with plain PHP objects and arrays, while HTTP responses and paginated lists use Laravel components:

Installation

Requirements

Basic Responder

Create a responder by extending AbstractResponder and implementing two methods:

Then compose a resource document:

The resulting payload follows the standard JSON:API shape:

By default, resourceId() returns $entity->id. Override it if your entity uses a different identifier.

Relationships

Define relationships in relationships() and pass the related records through withRelationData().

The relation data must be passed as a map keyed by the foreign key value:

If the foreign key is null, or the related object is missing from the map, the relationship value becomes null.

To-Many Relationships

Use ToManyRelationshipDefinition for grouped child resources:

Pass grouped data keyed by the parent entity field declared in entityKey:

Nested Relationship Data

If a child responder has its own relationships, pass that data through withNestedRelationData():

This is useful when a to-many relation needs nested linked resources without loading them inside the responder itself.

Includes

Top-level included resources are defined through includes():

Pass included entities as a flat array:

Paginated Lists

Use composeList() with Laravel's LengthAwarePaginator:

The package adds pagination metadata automatically:

HTTP Response Wrapper

YzendDev\Laravel\JsonApiResponse\Responder\JsonResponse extends Laravel's JsonResponse and sets JSON:API headers:

In a controller, a typical response looks like this:

Headers set by default:

Error Responses

Validation Errors

Ready-to-use JSON:API Error Documents

The package also ships a few ready-made JSON response classes:

Global Exception Handling

In Laravel, the package works best when JSON:API error rendering is configured once in bootstrap/app.php.

With this approach, application code can throw domain-level exceptions and let Laravel convert them into JSON:API error documents in one place:

That keeps controllers and services focused on business logic while response formatting stays centralized.

Notes


All versions of laravel-json-api-response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/pagination Version ^10.0|^11.0|^12.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 yzen.dev/laravel-json-api-response contains the following files

Loading the files please wait ...