PHPackages                             shelob9/async - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. shelob9/async

ActiveLibrary[Queues &amp; Workers](/categories/queues)

shelob9/async
=============

Run asynchronous tasks for long-running operations in WordPress

113PHP

Since Apr 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Shelob9/wp-async-task)[ Packagist](https://packagist.org/packages/shelob9/async)[ RSS](/packages/shelob9-async/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Async Task Runner for the WordPress
===================================

[](#async-task-runner-for-the-wordpress)

Create one time asynchronous tasks for WordPress

Forked from The WP Asynchronous Tasks plugin for TechCrunch.com -

How To Use
----------

[](#how-to-use)

Make sure to install as a composer dependnecy in plugin/site/app/whatever and include your autoloader.

### Conceptual Understanding

[](#conceptual-understanding)

- Read original version readme :

    -
- Read my article about using original version

    -
- Basically:

    - Create a class that extends `shelob9\async\task`
        - set action name in protected property `$action`
        - Prepare data to send to aync task in protected method `prepare_data()`
        - Prepare data and fire action for processing in protected method `prepare_data`
        - Optionally add public method `callback` to call with async task
    - Create new instance of `shelob9\async\system`
        - pass it an object -- insantiate you must -- of your `helob9\async\task` class as first parameter
        - Optionally pass, as second parameter, the callback function for the async task. Pass as string or array.
        - Optionally pass, as third parameter, an array of arguments for `do_action`. Should have priority in first index and number of callback params in second argument. Default is `[20,1]`.
- Consider:

    - Not calling a hook, or using system object, just calling a cb function right in `shelob9\async\task::run_action()`
    -

### Examples

[](#examples)

- With callback in class that defines task

```
    use shelob9\async\system;

    $task = new example();
    new system( $task, false, [ 20, 2 ] );

    class example extends shelob9\async\task {

        /**
         * Name of action
         *
         * @var string
         */
        protected $action = 'save_post';

        /**
         * Prepare async task -- runs when the original hook is fired
         *
         * @param array $data Dta passed to save_post hook
         *
         * @return array
         */
        protected function prepare_data( $data ) {
            $post_id = $data[0];
            return array( 'post_id' => $post_id );
        }

        /**
         * Runs the async hook in next session
         */
        protected function run_action() {
            $post_id = $_POST['post_id'];
            $post = get_post( $post_id );
            do_action( "wp_async_$this->action", $post->ID, $post );
        }

        /**
         * Process async task
         *
         * @param $id
         * @param $post
         */
        public function callback( $id, $post ){
            //do something here
        }

    }

```

- With callback as a function

```
    use shelob9\async\system;

    $task = new example();
    new system( $task, 'hi_roy', [ 20, 2 ] );

    class example extends shelob9\async\task {

        /**
         * Name of action
         *
         * @var string
         */
        protected $action = 'save_post';

        /**
         * Prepare async task -- runs when the original hook is fired
         *
         * @param array $data Dta passed to save_post hook
         *
         * @return array
         */
        protected function prepare_data( $data ) {
            $post_id = $data[0];
            return array( 'post_id' => $post_id );
        }

        /**
         * Runs the async hook in next session
         */
        protected function run_action() {
            $post_id = $_POST['post_id'];
            $post = get_post( $post_id );
            do_action( "wp_async_$this->action", $post->ID, $post );
        }

    }

    function hi_roy( $id, $post ){
        //do something here
    }

```

Copyright
---------

[](#copyright)

Copyright Josh Pollock 2016 -- Based heavily on TechCrunch WP Asynchronous Tasks plugin for TechCrunch.com -  - copyright 2014 TechCrunch. Much thanks, very open source

License
-------

[](#license)

This library is licensed under the [MIT](http://opensource.org/licenses/MIT) license. See LICENSE.md for more details.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

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

---

Top Contributors

[![nicolqs](https://avatars.githubusercontent.com/u/1183789?v=4)](https://github.com/nicolqs "nicolqs (3 commits)")[![johnpbloch](https://avatars.githubusercontent.com/u/446833?v=4)](https://github.com/johnpbloch "johnpbloch (2 commits)")[![ericmann](https://avatars.githubusercontent.com/u/605474?v=4)](https://github.com/ericmann "ericmann (1 commits)")[![JDGrimes](https://avatars.githubusercontent.com/u/4005415?v=4)](https://github.com/JDGrimes "JDGrimes (1 commits)")[![r-a-y](https://avatars.githubusercontent.com/u/505921?v=4)](https://github.com/r-a-y "r-a-y (1 commits)")[![Shelob9](https://avatars.githubusercontent.com/u/1994311?v=4)](https://github.com/Shelob9 "Shelob9 (1 commits)")

### Embed Badge

![Health badge](/badges/shelob9-async/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.5M29](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6045.5M504](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[jayazhao/think-queue-rabbitmq

为 ThinkPHP5.1 队列增加 RabbitMQ 驱动

141.5k](/packages/jayazhao-think-queue-rabbitmq)

PHPackages © 2026

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