Download the PHP package phphd/exception-handler-bundle without Composer

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

PhdExceptionHandlerBundle

🧰 Provides Symfony Messenger middlewares tailored for exception handling. You can easily re-raise exceptions, chain them, or handle with a dedicated bus.

Build Status Codecov Psalm coverage Psalm level Packagist Downloads Licence

Installation 📥

  1. Install via composer

  2. Enable the bundle in the bundles.php

Configuration ⚒️

To leverage features of this bundle, you should add phd_exception_handler middleware to the list:

The core principle of exception handling revolves around the idea that exceptions are dispatched to the corresponding bus to be handled. There must be one exception bus per one origin bus.

The exception bus name convention is straightforward: command.bus exceptions are forwarded into command.exception.bus.

Currently, there are few exception handling middlewares provided.

Rethrowing unhandled

Middleware: phd_exception_rethrow_unhandled

In case if dispatched exception had not been handled it is rethrown back. The exception is considered as handled if handler returns a response, or throws another exception.

Exception chaining

Middleware: phd_exception_chaining

Implements automatic exceptions escalation logic with #[RaiseAs] attribute.

Result filter

Middleware: phd_exception_result_filter

Filters out all null results of exception handlers.

Usage 🚀

Re-Raising Exceptions

The simplest use-case is defining #[RaiseAs] attribute on your exception class:

In this example, any time NonWhiteListedUserException is thrown from an underlying handler, it will be raised as AccessDeniedHttpException.

As you can see, there's required attribute bus option. Since some exceptions could be thrown from multiple different contexts (hence, different buses), it is required to explicitly specify the bus from which the particular exception must be raised, so that in other scenarios another exceptions could be escalated:

In this example, ImportLockedException could be thrown either in http context (api.bus), or in the mq consumer context (consumer.bus). Therefore, raised exceptions are different.

Manual Handling

The exception is dispatched down to your custom handlers, where you could either return a Response, throw a new exception, or just log it and return null so that exception will be re-thrown again.

If you would like to use the same exception handler for multiple exception buses, you can do so by adding multiple #[AsMessageHandler] attributes:


All versions of exception-handler-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/dependency-injection Version ^6.0 | ^7.0
symfony/http-kernel Version ^6.0 | ^7.0
symfony/messenger Version ^6.2 | ^7.0
symfony/string Version ^6.0 | ^7.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 phphd/exception-handler-bundle contains the following files

Loading the files please wait ....