Download the PHP package hgh/exception-handler without Composer

On this page you can find all versions of the php package hgh/exception-handler. 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 exception-handler

Exception Handler

This package centralizes exceptions behaviour of projects. The duty of this package is to prevent to show unwanted exceptions to user. Actually sometimes you want some exceptions to be shown in output too. This package will handle both sides. All exceptions can use the predefined interfaces.

Table of contents

Installation

To install this package, require it via the composer.

Interfaces

There are 11 interfaces that exceptions can be implemented. The exceptions that are implemented from these interfaces will be log in the files by their type.

Interface Description
AlertInterface Mark exception as an alert exception
CriticalInterface Mark exception as a critical exception
DebugInterface Mark exception as a debug exception
EmergencyInterface Mark exception as a emergency exception
InfoInterface Mark exception as a info exception
NoticeInterface Mark exception as a notice exception
WarningInterface Mark exception as a warning exception
NotLog The exception will not be log
ShouldPublish The exception will publish in response handler, otherwise will replace with UnexpectedException
WithDescription The exception has extra description addition to exception message

How to use

Exception handling

First as a sample we define an exception class.

You can use exception handler directly.

Or use facade:

As you can see, the result of exception handling is the same exception, because it implements from ShouldPublish interface.

Let's define another exception to see another type of exception handling:

See, the result of exception handling is not the same. It is UnexpectedException because it doesn't implement the ShouldPublish interface.

Exception Logging

Another class exists here to log the exceptions. First before ExceptionHandler change the type of exception, log the exception, then handle it by ExceptionHanlder.
Let's define an exception.

Now it's the turn of the logger. You can use the direct service as below:

or use the facade:

then handle it and pass it to output. Basically it's better to extend the facade of package and define your own fileWriter to prevent defining the fileWriter each time.

By this way, before changing the exception by exception handler, you log every exception, and you will never miss them and on the other side, after handling the exceptions, you will never show to the user unwanted exceptions.


All versions of exception-handler with dependencies

PHP Build Version
Package Version
Requires hgh/helpers 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 hgh/exception-handler contains the following files

Loading the files please wait ....