PHPackages                             dimadin/backdrop - 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. dimadin/backdrop

ActiveLibrary

dimadin/backdrop
================

Backdrop

1.0.0(7y ago)01491GPL-2.0-or-laterPHPPHP &gt;=5.4

Since Sep 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dimadin/Backdrop)[ Packagist](https://packagist.org/packages/dimadin/backdrop)[ Docs](https://github.com/dimadin/Backdrop)[ RSS](/packages/dimadin-backdrop/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

Backdrop
========

[](#backdrop)

[![Build Status](https://camo.githubusercontent.com/9707a43b63eeca36f8d958b3ff4b4e794e2abf3657bdda20b83034fa1e4ad947/68747470733a2f2f7777772e7472617669732d63692e6f72672f64696d6164696e2f4261636b64726f702e7376673f6272616e63683d6d6173746572)](https://www.travis-ci.org/dimadin/Backdrop)[![Latest Stable Version](https://camo.githubusercontent.com/2bafe62c69055f13cbf527471c50503dabbd51b8c1efbb9b24bbbc919147c208/68747470733a2f2f706f7365722e707567782e6f72672f64696d6164696e2f4261636b64726f702f76657273696f6e)](https://packagist.org/packages/dimadin/backdrop)

Backdrop is a simple library that does one thing: allows you to run one-off tasks in the background.

How to Use
----------

[](#how-to-use)

Backdrop is available as Composer package that you can use in your project.

```
composer require dimadin/backdrop
```

Alternately, you can download and include all files from `/inc` directory in your project. In either case, you then need to register it with `Main::init()` not after `admin_init` hook.

In this example, we create task if option doesn't exist, pass parameter to it, and then schedule it, while also hooking initialization of Backdrop:

```
function my_awesome_function( $id ) {
	// Download initial data to my site. Might take a long time!
	$data = wp_remote_get( 'http://example.com/' . $id );

	if ( is_wp_error( $data ) ) {
		return $data;
	}

	update_option( 'initial_data', $data );
}

add_action( 'init', function () {
	if ( ! get_option( 'initial_data' ) ) {
		$task = new \dimadin\WP\Library\Backdrop\Task( 'my_awesome_function', get_current_user_id() );
		$task->schedule();
	}
} );

add_action( 'admin_init', [ '\dimadin\WP\Library\Backdrop\Main', 'init' ] );
```

API
---

[](#api)

Full code reference is available at .

### `Task::__construct( $callback [, $...] )`

[](#task__construct-callback---)

Creating a new task sets up all of the internal data for your task. Pass in your callback followed by your arguments to the function, and Backdrop will call it in a background process.

#### Arguments

[](#arguments)

- `$callback`: Callback method you want to use. Can be any callable type (including object methods and static methods) **except for anonymous functions**. Closures cannot be serialized, so they cannot be used for Backdrop callbacks. This is an internal PHP limitation.
- `$...`: Any other arguments you'd like to pass to your callback, as variable arguments. e.g. `new Task( 'a', 'b', 'c', 'd' )` maps to `a( 'b', 'c', 'd' )`

#### Return Value

[](#return-value)

None (constructor).

### `Task::schedule()`

[](#taskschedule)

Schedules your task to run. Typically runs after your page has been rendered, in a separate process.

Backdrop de-duplicates tasks based on the arguments passed in. For example, you can do `new Task( 'myfunc', 1 )` on every request, and only one will be run. After this has been run, the next call will schedule again.

To avoid this, you should pass in unique identifiers as needed. Everything that makes your task unique should be passed in and used by your function, as global state may change.

#### Arguments

[](#arguments-1)

None.

#### Return Value

[](#return-value-1)

Either `true`, or a `WP_Error` on failure. The error object will indicate the type of error; typically this is a `md_backdrop_scheduled` if the task is already scheduled to run or is currently running.

### `Task::is_scheduled()`

[](#taskis_scheduled)

Checks whether your task is scheduled to run.

#### Arguments

[](#arguments-2)

None.

#### Return Value

[](#return-value-2)

Boolean indicating whether your task is scheduled to run, or is already running.

### `Task::cancel()`

[](#taskcancel)

Cancels a previously scheduled task.

Note that if the task is already running, this will not cancel execution; it simply removes it from the tasks scheduled to run.

#### Arguments

[](#arguments-3)

None.

#### Return Value

[](#return-value-3)

Either `true`, or a `WP_Error` on failure. The error object will indicate the type of error; typically this is a `md_backdrop_not_scheduled` if the task hasn't been scheduled.

### `Main::init()`

[](#maininit)

Register Backdrop.

#### Arguments

[](#arguments-4)

None.

#### Return Value

[](#return-value-4)

None.

Compatibility
-------------

[](#compatibility)

Backdrop is compatible with PHP 5.4 and upwards.

License
-------

[](#license)

Backdrop is licensed under the GPL version 2.

Copyright 2014 Human Made Limited, 2015-2018 Milan Dinić

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55% 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

2794d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54c4bd393dafccafaf09bf6441bbd933db30b4d4fd153211f79636e8838cdac5?d=identicon)[dimadin](/maintainers/dimadin)

---

Top Contributors

[![dimadin](https://avatars.githubusercontent.com/u/2678421?v=4)](https://github.com/dimadin "dimadin (22 commits)")[![rmccue](https://avatars.githubusercontent.com/u/21655?v=4)](https://github.com/rmccue "rmccue (7 commits)")[![willmot](https://avatars.githubusercontent.com/u/308507?v=4)](https://github.com/willmot "willmot (7 commits)")[![scottbasgaard](https://avatars.githubusercontent.com/u/91581?v=4)](https://github.com/scottbasgaard "scottbasgaard (1 commits)")[![mattheu](https://avatars.githubusercontent.com/u/494927?v=4)](https://github.com/mattheu "mattheu (1 commits)")[![joehoyle](https://avatars.githubusercontent.com/u/161683?v=4)](https://github.com/joehoyle "joehoyle (1 commits)")[![johnbillion](https://avatars.githubusercontent.com/u/208434?v=4)](https://github.com/johnbillion "johnbillion (1 commits)")

### Embed Badge

![Health badge](/badges/dimadin-backdrop/health.svg)

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

PHPackages © 2026

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