PHPackages                             derywat/php-abortable - 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. derywat/php-abortable

ActiveLibrary

derywat/php-abortable
=====================

PHP library to manage aborting code execution.

0.1.1(2mo ago)026MITPHP

Since Dec 11Pushed 2mo agoCompare

[ Source](https://github.com/derywat/php-abortable)[ Packagist](https://packagist.org/packages/derywat/php-abortable)[ RSS](/packages/derywat-php-abortable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

PHP library for aborting method execution.
==========================================

[](#php-library-for-aborting-method-execution)

Overview
========

[](#overview)

Library allows aborting code by use of AbortController.

Usage
=====

[](#usage)

Abortable method in class
-------------------------

[](#abortable-method-in-class)

Implement abortable methods by using AbortableTrait in your class.
In places where it's safe to abort methods code, check for abort and exit or throw. AbortException may be used to abort any method and catch aborted state in caller code.

```
use derywat\abortable\AbortableInterface;
use derywat\abortable\AbortableTrait;

class MyClass implements AbortableInterface {
	use AbortableTrait;

	protected function myAbortableMethod(){

		while($codeRuns){

			/*
			 *  some code block that cannot be aborted
			 */

			//check conditions and abort in places where it's safe to abort
			if($this->isAborted()){
				//do some cleanup and abort execution

				//AbortException can be used to abort execution and catch in caller
				throw new AbortException('abort request received.');
			}

			/*
			 *  some code block that cannot be aborted
			 */

			//check multiple times if needed...
			if($this->isAborted()){
				//do some cleanup and abort execution
				throw new AbortException('abort request received.');
			}

		}

	}

}
```

Aborting from caller code
-------------------------

[](#aborting-from-caller-code)

### Using AbortController with single or multiple abort closures

[](#using-abortcontroller-with-single-or-multiple-abort-closures)

Any number of abort closures may be added to AbortController. Abort closures will run every time when MyClass calls isAborted method.
Closure runs in the same process as abortable code. Returning true from closure will result in isAborted returning true. Catching AbortException allows to check if method was aborted.

```
use derywat\abortable\AbortController;
use derywat\abortable\AbortException;

$instance = new MyClass();

$instance->registerAbortController(
	(new AbortController())
		->addClosure(
			function():bool {
				//check conditions for abort
				//return true if code should abort
				//false otherwise
			}
		)
		->addClosure(
			function():bool {
				//another closure...
			}
		)
);

//running abortable method
try {
	$instance->myAbortableMethod();
	//myAbortableMethod returns to here if not aborted
} catch(AbortException $e){
	//this code runs if myAbortableMethod was aborted
}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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 ~69 days

Total

2

Last Release

89d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/derywat-php-abortable/health.svg)

```
[![Health](https://phpackages.com/badges/derywat-php-abortable/health.svg)](https://phpackages.com/packages/derywat-php-abortable)
```

PHPackages © 2026

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