PHPackages                             leocarmo/graceful-shutdown-php - 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. leocarmo/graceful-shutdown-php

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

leocarmo/graceful-shutdown-php
==============================

Graceful Shutdown for PHP

1.0.0(5y ago)18108.2k—5.7%3MITPHPPHP ^7.4 || ^8.0

Since May 1Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Graceful Shutdown with PHP
==========================

[](#graceful-shutdown-with-php)

[![Build Status](https://camo.githubusercontent.com/79ba682270f78774efdd59459500851668541cc79122c6eba242829e084ab8a7/68747470733a2f2f7472617669732d63692e6f72672f6c656f6361726d6f2f677261636566756c2d73687574646f776e2d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/leocarmo/graceful-shutdown-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7cc9bd29a0e2b08a43ff3dd517a6f05aafc046c4158e8caa36eb2007dd4a8471/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656f6361726d6f2f677261636566756c2d73687574646f776e2d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/leocarmo/graceful-shutdown-php/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/58e0bcfa27de42567c7fdb4040ab0c49dda871a07374a3ca1f65dca36ddde73d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656f6361726d6f2f677261636566756c2d73687574646f776e2d7068702f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Total Downloads](https://camo.githubusercontent.com/9ffc986d1bc5e1982c1c4903505d955da9fc06db661b5882a1767eb753885b53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c656f6361726d6f2f677261636566756c2d73687574646f776e2d7068702e737667)](https://packagist.org/packages/leocarmo/graceful-shutdown-php)

> Generally, a graceful shutdown is preferable in the case of any OS that saves its state. When the standard shutdown procedures are not done with these OSs, the result can be data corruption of program and operating system files. The result of the corruption can be instability, incorrect functioning or failure to boot.

For more information see [this](https://whatis.techtarget.com/definition/graceful-shutdown-and-hard-shutdown).

Composer
--------

[](#composer)

`composer require leocarmo/graceful-shutdown-php`

How to use
----------

[](#how-to-use)

This is very simple, you just have to call the `check` method inside a while loop and the magic will happen.

```
use LeoCarmo\GracefulShutdown\GracefulShutdown;

$shutdown = new GracefulShutdown();

while (! $shutdown->signalReceived()) {

    echo 'Start long task...' . PHP_EOL;
    sleep(sleep(5)); // --> when a signal is sent, sleep returns the number of seconds left
    echo 'End long task...' . PHP_EOL;

}

echo 'Graceful shutdown!';
```

Output result with debug enabled:

```
Start long task...
End long task...
Start long task...
^C##################### ---> Signal received: [2]
End long task...
Graceful shutdown!

```

Run `make run-exemple` to see this in action

Roadmap
-------

[](#roadmap)

- Tests

Credits
-------

[](#credits)

- [Leonardo Carmo](https://github.com/leocarmo)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/18bacea56d6c1c0be251f3293138255ff9212d19eb665fda3712732d23e688c6?d=identicon)[leocarmo](/maintainers/leocarmo)

---

Top Contributors

[![leocarmo](https://avatars.githubusercontent.com/u/21243754?v=4)](https://github.com/leocarmo "leocarmo (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leocarmo-graceful-shutdown-php/health.svg)

```
[![Health](https://phpackages.com/badges/leocarmo-graceful-shutdown-php/health.svg)](https://phpackages.com/packages/leocarmo-graceful-shutdown-php)
```

PHPackages © 2026

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