Download the PHP package dev-toolbelt/jsend-payload without Composer

On this page you can find all versions of the php package dev-toolbelt/jsend-payload. 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 jsend-payload

JSend Payload

CI Coverage Latest Stable Version Total Downloads License PHP Version

A framework-agnostic PHP library for building standardized API responses following the JSend specification. Provides a simple trait that can be mixed into any controller or handler to generate consistent JSON responses with PSR-7 support.

Features

Requirements

Installation

Quick Start

Add the AnswerTrait to your controller and start returning standardized responses:

Understanding JSend

JSend is a specification for a simple, standardized format for JSON responses from web servers. It defines three response types:

Status Description When to Use
success All went well, data is returned Successful GET, POST, PUT, DELETE operations
fail Problem with submitted data or call conditions Validation errors, missing required fields
error Server error occurred Exceptions, database failures, unexpected errors

Usage

Success Responses

Use for successful operations that return data:

Fail Responses

Use when there's a problem with the data submitted:

Error Responses

Use for server-side errors:

No Content Response

Use when operation succeeds but there's no data to return:

Helper Methods

The trait includes convenient methods for common API scenarios:

Method HTTP Code Description
answerSuccess($data) 200 Successful response with data
answerFail($data) 400 Client error with validation details
answerError($message) 500 Server error with message
answerNoContent() 200 Success with null data
answerInvalidUuid() 400 Invalid UUID format error
answerRecordNotFound() 404 Record not found error
answerEmptyPayload() 400 Empty request body error
answerRequired($field) 400 Required field missing error
answerColumnNotFound($column) 400 Database column not found error

Response Examples

answerInvalidUuid()

answerRecordNotFound()

answerRequired('email')

Framework Integration

Slim Framework

Laravel

Note: Laravel requires the nyholm/psr7 bridge or similar PSR-7 adapter for full compatibility.

Mezzio (formerly Zend Expressive)

Symfony

Note: Symfony requires the PSR-7 Bridge (symfony/psr-http-message-bridge) for PSR-7 response compatibility.

Yii2

Note: For Yii2, you may need to configure your application to handle PSR-7 responses or convert them using yiisoft/yii2-psr7-bridge.

CakePHP 5

Note: CakePHP 5 has native PSR-7 support. For CakePHP 4, the integration works similarly.

CodeIgniter 4

Note: CodeIgniter 4 supports PSR-7 through the codeigniter4/psr7bridge package for full compatibility.

Testing

Security

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

Code Quality Requirements

Check Tool Requirement
Tests PHPUnit All tests must pass
Coverage PCOV Minimum 85% coverage
Code Style PHP CodeSniffer PSR-12 compliant
Static Analysis PHPStan Level 6, no errors

Pull Request Guidelines

Before submitting a PR, ensure:

  1. All tests pass: composer test
  2. Coverage is at least 85%: composer test:coverage
  3. Code style is correct: composer phpcs
  4. No static analysis errors: composer phpstan

Important: Pull requests with coverage below 85% will be automatically blocked by CI.

Coverage Report

License

MIT License. See LICENSE for details.


All versions of jsend-payload with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
dev-toolbelt/enums Version ^1.0
nyholm/psr7 Version ^1.8
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 dev-toolbelt/jsend-payload contains the following files

Loading the files please wait ...