Download the PHP package kuria/error without Composer

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

Error handler #############

Makes handling and debugging PHP errors suck less.

:depth: 2

Features

Requirements

Usage example

$debug = true; // true during development, false in production error_reporting(E_ALL); // configure the error reporting

$errorHandler = new ErrorHandler(); $errorHandler->setDebug($debug); $errorHandler->register();

// trigger an error to see the error handler in action echo $invalidVariable;

Event system

Error handler events

Possible events emitted by the ErrorHandler class are listed in ErrorHandlerEvents:

ErrorHandlerEvents::ERROR

Emitted when a PHP errors occurs.

Arguments:

  1. Kuria\Error\Exception\ErrorException $exception
    • you may use the suppress() or force() method to suppress or force the exception, respectivelly, regardless of the error_reporting PHP setting
  2. bool $debug

ErrorHandlerEvents::EXCEPTION

Emitted when an uncaught exception or a fatal error is being handled.

Arguments:

  1. Throwable $exception
  2. bool $debug

ErrorHandlerEvents::FAILURE

Emitted when an uncaught exception or a fatal error could not be handled. This can happen when an exception event listener or the registered error screen throws an additional exception. Throwing another exception or causing a fatal error at this point will just kill the script.

Arguments:

  1. Throwable $exception
  2. bool $debug

Web error screen events

Possible events emitted by the WebErrorScreen class are listed in WebErrorScreenEvents:

WebErrorScreenEvents::RENDER

Emitted when rendering in normal mode.

Receives an array with the following keys:

WebErrorScreenEvents::RENDER_DEBUG

Emitted when rendering in debug mode.

Receives an array with the following keys:

WebErrorScreenEvents::CSS

Emitted when CSS styles are being output.

Receives a single boolean value indicating debug mode.

WebErrorScreenEvents::JS

Emitted when JavaScript code is being output.

Receives a single boolean value indicating debug mode.

CLI error screen events

Possible events emitted by the CliErrorScreen class are listed in CliErrorScreenEvents:

CliErrorScreenEvents::RENDER

Emitted when rendering in normal mode.

Receives an array with the following keys:

CliErrorScreenEvents::RENDER_DEBUG

Emitted when rendering in debug mode.

Receives an array with the following keys:ng keys:

Event listener examples

Logging

Logging uncaught exceptions into a file:

$errorHandler->on(ErrorHandlerEvents::EXCEPTION, function (\Throwable $exception, bool $debug) { $logFilePath = sprintf('./errors%s.log', $debug ? 'dev' : 'prod');

$entry = sprintf( "[%s] %s: %s in file %s on line %d\n", date('Y-m-d H:i:s'), Error::getExceptionName($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() );

file_put_contents($logFilePath, $entry, FILE_APPEND | LOCK_EX);

});

Disabling the "@" operator

This listener causes statements like echo @$invalidVariable; to throw an exception regardless of the "shut-up" operator.

$errorHandler->on(ErrorHandlerEvents::ERROR, function (ErrorException $exception, bool $debug) { $exception->force(); });

Altering the error screens

Changing default labels in normal mode:

$errorScreen = $errorHandler->getErrorScreen();

if (!$errorHandler->isDebugEnabled() && $errorScreen instanceof WebErrorScreen) { $errorScreen->on(WebErrorScreenEvents::RENDER, function ($event) { $event['heading'] = 'It is all your fault!'; $event['text'] = 'You have broken everything and now I hate you.'; }); }

Adding a customized section to the debug screen:

$errorScreen = $errorHandler->getErrorScreen();

if ($errorHandler->isDebugEnabled() && $errorScreen instanceof WebErrorScreen) { // add custom CSS $errorScreen->on(WebErrorScreenEvents::CSS, function () { echo '#custom-group {color: #f60000;}'; });

// add custom HTML $errorScreen->on(WebErrorScreenEvents::RENDER_DEBUG, function (array $view) { $view['extras'] .= <<<HTML

<div id="custom-group" class="group"> <div class="section"> Example of a custom section </div> </div> HTML; }); }


All versions of error with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
kuria/event Version ^2.0
kuria/debug Version ^4.0
kuria/php-highlighter Version ^2.0 || ^3.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 kuria/error contains the following files

Loading the files please wait ....