Download the PHP package phauthentic/error-response without Composer

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

RFC 9457: Problem Details for HTTP APIs

PHP >= 8.1 phpstan Level 8 License: MIT

This library is an implementation of RFC 9457.


HTTP status codes cannot always convey enough information about errors to be helpful. While humans using web browsers can often understand an HTML response content, non-human consumers of HTTP APIs have difficulty doing so.

To address that shortcoming, RFC 9457 defines simple JSON and XML document formats to describe the specifics of a problem encountered.

For example, consider a response indicating that the client's account doesn't have enough credit. The API's designer might decide to use the 403 Forbidden status code to inform generic HTTP software (such as client libraries, caches, and proxies) of the response's general semantics. API-specific problem details (such as why the server refused the request and the applicable account balance) can be carried in the response content so that the client can act upon them appropriately (for example, triggering a transfer of more credit into the account).

Installation

Documentation

It is recommended to read the RFC 9457 at least briefly to understand the RFC and how the actual implementation helps you.

Middleware

The ErrorResponseMiddleware is a PSR-15 middleware designed to handle exceptions thrown during the execution of a request and convert them into RFC 9457 conforming error responses.

The middleware takes two argumens:

  1. A PSR7 Response Factory implementing Psr\Http\Message\ResponseFactoryInterface.
  2. An array of exception class names that the middleware should intercept. If an exception is an instance of any of these classes, it will be converted into an error response.

Use a proper class hierarchy for your exceptions! For example, have a DatabaseAccessLayerException from which you derive sub-types instead of declaring hundreds of exception classes and pass them to the middleware.

Error Responses

Error Responses can be constructed using one of the provided factories or by instantiating the ErrorResponse directly.

License

Copyright Florian Krämer

Licensed under the MIT license.


All versions of error-response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-middleware 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 phauthentic/error-response contains the following files

Loading the files please wait ....