PHPackages                             jitsu/error - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jitsu/error

ActiveLibrary

jitsu/error
===========

Sane PHP error handling and silencing

0.2.0(9y ago)093MITPHPPHP &gt;=5.3.0

Since Sep 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bdusell/jitsu-error)[ Packagist](https://packagist.org/packages/jitsu/error)[ RSS](/packages/jitsu-error/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (5)Used By (0)

jitsu/error
-----------

[](#jitsuerror)

This package is used to override PHP's default error and exception handlers with more disciplined behavior, an absolutely essential measure which greatly aids debugging during development and makes for more secure applications in production.

This package is part of [Jitsu](https://github.com/bdusell/jitsu).

Installation
------------

[](#installation)

Install this package with [Composer](https://getcomposer.org/):

```
composer require jitsu/error
```

About
-----

[](#about)

It's no secret that PHP's default error handling behavior is terrible, and that its arbitrary distinction between "errors" and exceptions makes little sense. This package defines a function, `Jitsu\bootstrap()`, which overrides PHP's default error handlers at a global level with more sensible behavior. Specifically, it registers a simple error handler which converts all errors to `ErrorException`s which can be caught and handled, and also registers a global exception handler which optionally prints a full stack trace before exiting.

Note that the overrides do not restrict you in any way from intercepting and handling exceptions/errors before they reach the global handlers; this merely changes how *unhandled* exceptions and errors are reported (or not reported). The global overrides are primarily useful for debugging, since by default errors do not halt the script and can easily go unnoticed. However, they are equally important when an application is deployed in a live environment, for they ensure that stack traces and other sensitive information are not shown to end users. After calling `Jitsu\bootstrap()`, you still can and should wrap your code in a `try`/`catch` block with application-specific error handling logic. This would allow you, for instance, to display a custom 500 error page.

The very first commands in your PHP script should be:

```
