PHPackages                             adlacruzes/php-base-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. [Queues &amp; Workers](/categories/queues)
4. /
5. adlacruzes/php-base-exception

ActiveLibrary[Queues &amp; Workers](/categories/queues)

adlacruzes/php-base-exception
=============================

PHP base exception with default message and custom value

2.5.0(3y ago)037.4k—0%1MITPHPPHP ^7.2 || ^8.0

Since Feb 10Pushed 3y agoCompare

[ Source](https://github.com/adlacruzes/php-base-exception)[ Packagist](https://packagist.org/packages/adlacruzes/php-base-exception)[ RSS](/packages/adlacruzes-php-base-exception/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (10)Used By (1)

PHP Base exception
==================

[](#php-base-exception)

[![Minimum PHP Version](https://camo.githubusercontent.com/4f9eddea3b5f90bdf4c2f6feafb71962a03512fd923888e4aef358cf6334daf7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Packagist](https://camo.githubusercontent.com/180797b764780272d7d4e406b7033232cd50f6b6c556fd99746e2f90e9239cf8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61646c616372757a65732f7068702d626173652d657863657074696f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adlacruzes/php-base-exception)[![Github actions](https://github.com/adlacruzes/php-base-exception/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/adlacruzes/php-base-exception/workflows/Continuous%20Integration/badge.svg?branch=master)

PHP base exception is a library that provides exceptions with a default message and a custom value in an easy way.

Requirements
------------

[](#requirements)

PHP needs to be a minimum version of PHP 7.2.

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

[](#installation)

The recommended way to install is through Composer.

```
composer require adlacruzes/php-base-exception
```

Usage
-----

[](#usage)

Create an exception that extends from BaseException.

```
use Adlacruzes\Exceptions\BaseException;

class SomethingNotFoundException extends BaseException {}
```

Then the exception can be called with no arguments.

```
try {
    throw new SomethingNotFoundException();
} catch (SomethingNotFoundException $e) {
    echo $e->getMessage();
}
```

The method `getMessage()` returns an auto generated message based on the class name without typing anything more.

```
echo $e->getMessage();
// Something not found
```

### Default message

[](#default-message)

You can choose a default message instead. Just initialize the message variable.

```
class SomethingNotFoundException extends BaseException {

    /**
     * @var mixed
     */
    protected $message = 'This is a default message';

}
```

```
try {
    throw new SomethingNotFoundException();
} catch (SomethingNotFoundException $e) {
    echo $e->getMessage();
}
```

```
echo $e->getMessage();
// This is a default message
```

### Message with contextual information

[](#message-with-contextual-information)

In addition to the message, you can provide more information to the exception and it will append to the result.

```
try {
    throw new SomethingNotFoundException('information');
} catch (SomethingNotFoundException $e) {
    echo $e->getMessage();
}
```

And the output will be:

```
echo $e->getMessage();
// Something not found: information
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~200 days

Total

9

Last Release

1273d ago

Major Versions

1.0.1 → 2.0.02019-07-09

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.0PHP ^7.2

2.1.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae206f49d348a5b75a51accb50e1d1ffb4524fdd6dbfcd4827ad8d5654b5087d?d=identicon)[adlacruzes](/maintainers/adlacruzes)

---

Top Contributors

[![adlacruzes](https://avatars.githubusercontent.com/u/31167513?v=4)](https://github.com/adlacruzes "adlacruzes (59 commits)")

---

Tags

exceptionexception-messagesexceptionsphpmessageexceptioncustom

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/adlacruzes-php-base-exception/health.svg)

```
[![Health](https://phpackages.com/badges/adlacruzes-php-base-exception/health.svg)](https://phpackages.com/packages/adlacruzes-php-base-exception)
```

###  Alternatives

[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k125.3M879](/packages/php-amqplib-php-amqplib)[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M65](/packages/php-amqplib-rabbitmq-bundle)[bunny/bunny

Performant pure-PHP AMQP (RabbitMQ) non-blocking ReactPHP library

7426.5M37](/packages/bunny-bunny)[aws/aws-php-sns-message-validator

Amazon SNS message validation for PHP

21421.5M91](/packages/aws-aws-php-sns-message-validator)[simple-bus/message-bus

Generic classes and interfaces for messages and message buses

3455.7M30](/packages/simple-bus-message-bus)[sabas/edifact

Tools in PHP for UN/EDIFACT

2881.6M7](/packages/sabas-edifact)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
