PHPackages                             imliam/php-catch-exit - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. imliam/php-catch-exit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

imliam/php-catch-exit
=====================

Gracefully handle an unwanted exit statement.

v1.0.0(7y ago)4335MITPHPPHP ^7.1

Since Sep 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ImLiam/php-catch-exit)[ Packagist](https://packagist.org/packages/imliam/php-catch-exit)[ Docs](https://github.com/imliam/php-catch-exit)[ RSS](/packages/imliam-php-catch-exit/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP Catch Exit Statements
=========================

[](#php-catch-exit-statements)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4815b635edd6d7b9e43f783408694828dd80503e6c68cc9513475c7cc89d630f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6c69616d2f7068702d63617463682d657869742e737667)](https://packagist.org/packages/imliam/php-catch-exit)[![Total Downloads](https://camo.githubusercontent.com/d6defd3ce55e309bdda34aee0b55de55c72d2b42c28bb738c26d9a3b3194dac0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6c69616d2f7068702d63617463682d657869742e737667)](https://packagist.org/packages/imliam/php-catch-exit)[![License](https://camo.githubusercontent.com/7c360eecab8951e74a436e4e2cf0befd381a168619cb3363e343586b931472a1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696d6c69616d2f7068702d63617463682d657869742e737667)](LICENSE.md)

Gracefully handle an unwanted exit statement.

- [PHP Catch Exit Statements](#php-catch-exit-statements)
    - [🤔 F.A.Q.](#%F0%9F%A4%94-faq)
        - [Why would you need this?](#why-would-you-need-this)
        - [So why do this?](#so-why-do-this)
    - [💾 Installation](#%F0%9F%92%BE-installation)
    - [📝 Usage](#%F0%9F%93%9D-usage)
        - [Print a string](#print-a-string)
        - [Execute a closure](#execute-a-closure)
    - [🔖 Changelog](#%F0%9F%94%96-changelog)
    - [⬆️ Upgrading](#%E2%AC%86%EF%B8%8F-upgrading)
    - [🎉 Contributing](#%F0%9F%8E%89-contributing)
        - [🔒 Security](#%F0%9F%94%92-security)
    - [👷 Credits](#%F0%9F%91%B7-credits)
    - [♻️ License](#%E2%99%BB%EF%B8%8F-license)

🤔 F.A.Q.
--------

[](#-faq)

### Why would you need this?

[](#why-would-you-need-this)

This shouldn't be needed at all, really. There is virtually no practical reason to have an `exit` statement over an exception in a modern PHP application, as all frameworks have their own decent, extendable exception handlers that should be taken full advantage of.

That said, a *lot* of beginners PHP tutorials end up showing the same sort of code for your first database connection:

```
