https://github.com/themeplate/process
Straightforward background processing tool
https://github.com/themeplate/process
background process tasks wordpress
Last synced: 4 months ago
JSON representation
Straightforward background processing tool
- Host: GitHub
- URL: https://github.com/themeplate/process
- Owner: ThemePlate
- License: gpl-3.0
- Created: 2020-02-20T23:01:07.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2025-03-01T07:19:14.000Z (over 1 year ago)
- Last Synced: 2025-03-01T08:03:14.297Z (over 1 year ago)
- Topics: background, process, tasks, wordpress
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThemePlate Process
## Usage
```php
use ThemePlate\Process\Async;
// Instantiate
$background = new Async( function() {
long_running_task();
} );
// Dispatch
$background->dispatch();
```
### new Async( $callback_func, $callback_args )
Execute a heavy one-off task via a non-blocking request
- **$callback_func** *(callable)(Required)* Function to run asynchronously
- **$callback_args** *(array)(Optional)* Parameters to pass in the callback. Default `null`
### ->dispatch()
Fire off the process in the background instantly
### ->then( $callback )
### ->catch( $callback )
Chainable methods to handle success or error
- **$callback** *(callable)(Optional)*
---
```php
use ThemePlate\Process\Tasks;
$chores = new Tasks( 'my_day' );
$chores->add( 'first_task', array( 'this', 'that' ) );
$chores->add( function() {
another_task();
} );
```
### new Tasks( $identifier )
- **$identifier** *(string)(Required)* Unique identifier
### ->add( $callback_func, $callback_args )
- **$callback_func** *(callable)(Required)* Function to run
- **$callback_args** *(array)(Optional)* Parameters to pass. Default `null`
### ->remove( $callback_func, $callback_args )
- **$callback_func** *(callable)(Required)* Supposed function to run
- **$callback_args** *(array)(Optional)* The parameters passed. Default `null`
### ->clear()
Remove all currently listed task
### ->limit( $number )
- **$number** *(int)(Required)* Number of task per run
### ->every( $second )
- **$second** *(int)(Required)* Interval between runs
### ->report( $callback )
- **$callback** *(callable)(Required)* To run after completion
### Helper methods
#### ->get_identifier()
#### ->dump()
#### ->is_running()
#### ->next_scheduled()
#### ->has_queued()
#### ->get_queued()