Download the PHP package crell/api-problem without Composer

On this page you can find all versions of the php package crell/api-problem. 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 api-problem

ApiProblem

Build Status

This library provides a simple and straightforward implementation of the IETF Problem Details for HTTP APIs, RFC 9457.

RFC 9457 is a simple specification for formatting error responses from RESTful APIs on the web. This library provides a simple and convenient way to interact with that specification. It supports generating and parsing RFC 9457 messages, in both JSON and XML variants.

Generating responses

What's that you say? Someone sent your API a bad request? Tell them it's a problem!

Or, even better, you can subclass ApiProblem for a specific problem type (since the type and title are supposed to go together and be relatively fixed), then just populate your own error-specific data. Just like extending an exception!

If you're using a library or framework that wants to do its own JSON serialization, that's also fully supported. ApiProblem implements\JsonSerializable, so you can pass it directly to json_encode() as if it were a naked array.

Sending Responses

You're probably using PSR-7 for your responses. That's why this library includes a utility to convert your ApiProblem object to a PSR-7 ResponseInterface object, using a PSR-17 factory of your choice. Like so:

That gives back a fully-functional and marked Response object, ready to send back to the client.

Receiving responses

Are you sending messages to an API that is responding with API-Problem errors? No problem! You can easily handle that response like so:

(It works for fromXml(), too!)

Installation

Install ApiProblem like any other Composer package:

composer require crell/api-problem

See the Composer documentation for more details.

Security

If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.

Credits

License

This library is released under the MIT license. In short, "leave the copyright statement intact, otherwise have fun." See LICENSE for more information.

Contributing

Pull requests accepted! The goal is complete conformance with the IETF spec.


All versions of api-problem with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.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 crell/api-problem contains the following files

Loading the files please wait ....