Download the PHP package nickjbedford/json-response without Composer

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

JsonResponse

The JsonResponse library for PHP defines a simple and uniform structure for JSON API responses, from success status to error information and data payloads.

All keys are guaranteed to exist, even if they are null. This ensures clients of an API do not have to waste time and code checking if standard properties exist before checking their values.

Success Responses

To create a success response, use either the \YetAnother\JsonResponse::success() method or the json_success() function.

Example

The basic response structure for a successful request without any data payload is as follows:

Field Type Description
success boolean true for a successful response, otherwise false for an error response.
error object or null null for successful responses, otherwise a JsonResponseError object.
data mixed or null An optional data payload containing any type of data including null. This will depend on the API request.

Error Responses

To create a failure response, use either the \YetAnother\JsonResponse::failure() method or the json_success() function.

Example

The basic response structure for a failed request is as follows:

Field Type Description
error.message string An error message for the client to display to the user.
error.code string or null An optional error code for the client to use in handling the error. This will depend on the API request.
error.data mixed or null Optional information about the error. This may contain debugging information about exceptions thrown by the server if provided.

Exception Error Responses

To create a failure response based on an exception, use either the \YetAnother\JsonResponse::exception() method or the json_exception() function.

Example

The response will contain the following data including the exception debug data:

If debugging data is included in the exception response, the error.data property will be structured as follows:

Field Type Description
error.data.class string The PHP class name of the exception throw.
error.data.file string The name of the PHP script where the exception occurred.
error.data.file int The line number in the PHP script where the exception occurred.
error.data.trace string The stack trace formatted as a string.

Record Sets

To create a standardised response for record set responses with paging information, use the \YetAnother\JsonResponse::recordSet() method or json_records() function.

Example

The response will contain the following data:

Field Type Description
data.records array An array containing the page's records.
data.page int The zero-based page index for the current record set.
data.pageLength int The length of each page in the query.
data.total int The total number of records in the query.
data.nextPage int or null The next page's index if there are more records, otherwise null.
data.previousPage int or null The previous page's index if the current page index is non-zero, otherwise null.
data.recordType string or null An optionally provided name of the type of records in the record set. This is defined by the API using the library.

All versions of json-response with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 nickjbedford/json-response contains the following files

Loading the files please wait ....