Download the PHP package mnavarrocarter/problem-details without Composer

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

ApiException (RFC7807 Implementation)

ApiException is an abstract exception class for php that implements the RFC7807 problem details structure.

It is ment to be extended into other exception classes that define specific error types, according to the RFC.

Installing

Simply do:

composer require mnavarrocarter/problem-details

Usage

Creating your custom Exception Types

For the different problem types in your api, you must create meaningful exception classes that will extend this abstract one, and override the constructor to set your custom type, title and, if you want, status code.

Using Factory Pattern to simplify error creation.

Now, with your class created, you can use the factory pattern to quickly and simply create new instances of the custom error type you just created.

Then, in your client code:

Then, at your controller level, you can catch these exceptions to provide a response. Or, if you use frameworks like Symfony, you can configure an Exception Listener.

If you noticed, the ApiException implements PHP's \JsonSerializable interface. So it is easily serialized with a simple json_encode(). If you want to just normalize the object, you can call the toArray() method.

Modifiying the implementation

tldr; You can't. You can implement the interface though.

This implementation is very closed. Property visibility is hidden from you, and you can only interact with the properties via the public methods.

Also, the implementation methods are declared final, so you can't override them. This will protect you from breaking anything, as this class is developed to always provide a meaningful response by checking stuff in getters and setters.

The interface is there in case you want to create your own implementation.


All versions of problem-details with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 mnavarrocarter/problem-details contains the following files

Loading the files please wait ....