PHPackages                             yiisoft/friendly-exception - 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. [Framework](/categories/framework)
4. /
5. yiisoft/friendly-exception

ActiveLibrary[Framework](/categories/framework)

yiisoft/friendly-exception
==========================

An interface for friendlier exception

1.2.0(5mo ago)491.8M—5.7%9[1 issues](https://github.com/yiisoft/friendly-exception/issues)20BSD-3-ClausePHPPHP 7.4.\* || 8.0 - 8.5CI passing

Since Mar 4Pushed 4mo ago16 watchersCompare

[ Source](https://github.com/yiisoft/friendly-exception)[ Packagist](https://packagist.org/packages/yiisoft/friendly-exception)[ Docs](https://www.yiiframework.com/)[ GitHub Sponsors](https://github.com/sponsors/yiisoft)[ OpenCollective](https://opencollective.com/yiisoft)[ RSS](/packages/yiisoft-friendly-exception/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (7)Used By (20)

 [ ![Yii](https://camo.githubusercontent.com/8317c17418b39410a660f5149071d26c5023c0d5fb2b7ebb771324812f666d73/68747470733a2f2f796969736f66742e6769746875622e696f2f646f63732f696d616765732f7969695f6c6f676f2e737667) ](https://github.com/yiisoft)

Yii Friendly Exception
======================

[](#yii-friendly-exception)

[![Latest Stable Version](https://camo.githubusercontent.com/39e184d10816d1da717d85cdcbf8efc208d649a04a5fc25d7bb19c55fba30d09/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f667269656e646c792d657863657074696f6e2f76)](https://packagist.org/packages/yiisoft/friendly-exception)[![Total Downloads](https://camo.githubusercontent.com/f77597331b428f638c44b3f2518d8262a4cf56ac948a35110e59e5f4ef347280/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f667269656e646c792d657863657074696f6e2f646f776e6c6f616473)](https://packagist.org/packages/yiisoft/friendly-exception)

An exception interface that provides a friendly name and a possible solution. Error handlers may consider the interface to render additional information right at the error screen.

Example of implementation in [Yii Error Handler](https://github.com/yiisoft/error-handler):

   ![Frendly exception](docs/images/friendly-exception-light.png)Requirements
------------

[](#requirements)

- PHP 7.4 - 8.5.

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

[](#installation)

The package could be installed with [Composer](https://getcomposer.org):

```
composer require yiisoft/friendly-exception
```

General usage
-------------

[](#general-usage)

### Implementing friendly exception

[](#implementing-friendly-exception)

To make exception friendly require this package and implement `FriendlyExceptionInterface`:

```
use Yiisoft\FriendlyException\FriendlyExceptionInterface;

class RequestTimeoutException extends \RuntimeException implements FriendlyExceptionInterface
{
    public function getName(): string
    {
        return 'Request timed out.';
    }

    public function getSolution(): ?string
    {
        return
