Download the PHP package youssef/error without Composer

On this page you can find all versions of the php package youssef/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. Based on kuria/error (https://github.com/kuria/error)

Table of Contents

Features

Requirements

Usage example

use Kuria\Error\ErrorHandler;

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

$errorHandler = new ErrorHandler($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:

error

fatal

emerg

Web error screen events

Possible events emitted by the WebErrorScreen class:

render

render.debug

layout.css

layout.js

CLI error screen events

Possible events emitted by the CliErrorScreen class:

render

render.debug

Event listener examples

Notes

Logging

Logging unhandled errors into a file.

use Kuria\Error\Util\Debug;

$errorHandler->on('fatal', function ($exception, $debug) {
    $logFilePath = sprintf('./errors_%s.log', $debug ? 'debug' : 'prod');

    $entry = sprintf(
        "[%s] %s - %s in file %s on line %d\n",
        date('Y-m-d H:i:s'),
        Debug::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('error', function ($exception, $debug, &$suppressed) {
    $suppressed = false;
});

Altering the error screens

Examples for the web error screen.

Changing default labels of the non-debug error screen:

use Kuria\Error\Screen\WebErrorScreen;

$errorHandler->on('fatal', function ($exception, $debug, $screen) {
   if (!$debug && $screen instanceof WebErrorScreen) {
        $screen->on('render', function (&$view) {
            $view['heading'] = 'It is all your fault!';
            $view['text'] = 'You have broken everything and now I hate you.';
        });
    }
});

Adding customized section to the debug screen:

use Kuria\Error\Screen\WebErrorScreen;

$errorHandler->on('fatal', function ($exception, $debug, $screen) {
   if ($debug && $screen instanceof WebErrorScreen) {
        $screen
            ->on('layout.css', function (&$css) {
                $css .= '#custom-group {color: #f60000;}';
            })
            ->on('render.debug', function (&$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 >=5.3.0
kuria/event Version ~0.2.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 youssef/error contains the following files

Loading the files please wait ....