PHPackages                             internal/destroy - 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. internal/destroy

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

internal/destroy
================

1.0.0(8mo ago)55870.4k↓29.1%[1 PRs](https://github.com/php-internal/destroy/pulls)4BSD-3-ClausePHPPHP &gt;=8.1CI passing

Since Sep 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/php-internal/destroy)[ Packagist](https://packagist.org/packages/internal/destroy)[ Patreon](https://patreon.com/roxblnfk)[ RSS](/packages/internal-destroy/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (4)

[![Destroy](./resources/logo.svg)](./resources/logo.svg)

Destruction as a Service

[![Support](https://camo.githubusercontent.com/92a5c9c142a4b40702e8f5905faa1afae6cfc4f79c417502e83bce1e2c90cf5f/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f7374796c653d666c61742d737175617265266c6162656c3d537570706f7274266d6573736167653d254532253944254134266c6f676f3d47697448756226636f6c6f723d253233666530303836)](https://patreon.com/roxblnfk)

The package provides explicit resource management for PHP applications through the `Destroyable` interface. It solves memory leaks in long-running applications by enabling deterministic cleanup of resources and breaking circular reference chains that prevent garbage collection.

**Why Not Just `__destruct()`?**

PHP's `__destruct()` method has critical limitations with circular references. While simple two-object cycles (A → B → A) can sometimes be resolved by `gc_collect_cycles()`, more complex scenarios with three or more interconnected objects often fail to trigger destructors at all.

Additionally, `gc_collect_cycles()` has significant performance overhead, making frequent calls impractical in high-performance applications.

```
// Simple cycle - might be collected eventually
$a->ref = $b;
$b->ref = $a;

// Complex cycle - often never collected
$a->ref = $b;
$b->ref = $c;
$c->ref = $a;
```

The `Destroyable` interface provides explicit control over cleanup, ensuring resources are freed deterministically without relying on garbage collection cycles or performance-impacting manual collection calls.

Perfect for daemon processes, event-driven applications, and any scenario where deterministic resource cleanup is critical.

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

[](#installation)

```
composer require internal/destroy
```

[![PHP](https://camo.githubusercontent.com/8f3b8af3efaada247510936df8cbf5c635b1b79c67939a9e75de4cf417713128/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f696e7465726e616c2f64657374726f792e7376673f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://packagist.org/packages/internal/destroy)[![Latest Version on Packagist](https://camo.githubusercontent.com/80190f123871f437e074375882d05905da08c19252d4d7ff25eec7b86d36d3ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e7465726e616c2f64657374726f792e7376673f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://packagist.org/packages/internal/destroy)[![License](https://camo.githubusercontent.com/d969d4e108515eeb0450a2982c2f9c70fd109538fb9083df65a6ae8a8997e4f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696e7465726e616c2f64657374726f792e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Destroys](https://camo.githubusercontent.com/4e46311ef6ce772c66de340de549b8f40cb9f2b7b3b4828f79b0f60831c50210/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e7465726e616c2f64657374726f792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/internal/destroy/stats)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance74

Regular maintenance activity

Popularity50

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity45

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

Every ~170 days

Total

2

Last Release

82d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/110fa17dca123e71e4ef4132d1d6a66d20058a07fc6118e716dd67dd4316e886?d=identicon)[roxblnfk](/maintainers/roxblnfk)

---

Top Contributors

[![roxblnfk](https://avatars.githubusercontent.com/u/4152481?v=4)](https://github.com/roxblnfk "roxblnfk (12 commits)")

---

Tags

gcmemoryphpmemorydownload binaries

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/internal-destroy/health.svg)

```
[![Health](https://phpackages.com/badges/internal-destroy/health.svg)](https://phpackages.com/packages/internal-destroy)
```

###  Alternatives

[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[weareferal/matrix-field-preview

Add screenshot previews to matrix and neo fields, helping you publish content quicker.

1717.5k](/packages/weareferal-matrix-field-preview)[php-school/psx

PHP CLI Syntax Highlighter

195.1k](/packages/php-school-psx)

PHPackages © 2026

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