PHPackages                             weidizhang/php-timed-tasks - 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. weidizhang/php-timed-tasks

ActiveLibrary

weidizhang/php-timed-tasks
==========================

Easily manage and create multiple timed tasks with PHP

110PHP

Since Aug 28Pushed 9y agoCompare

[ Source](https://github.com/weidizhang/PHP-Timed-Tasks)[ Packagist](https://packagist.org/packages/weidizhang/php-timed-tasks)[ RSS](/packages/weidizhang-php-timed-tasks/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Timed-Tasks
===============

[](#php-timed-tasks)

Created by Weidi Zhang

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

[](#installation)

```
composer require weidizhang/php-timed-tasks:dev-master

```

Usage
-----

[](#usage)

First, require the autoloader and use the classes.

```
require "vendor/autoload.php";

use weidizhang\PHPTimedTasks\Task;
use weidizhang\PHPTimedTasks\TimedTaskManager;

```

Create a new TimedTaskManager object

```
$manager = new TimedTaskManager();

```

### Using lambda functions

[](#using-lambda-functions)

```
$manager->addTask(
	new Task(function() {
		echo "[" . date("h:i:s A") . "] Hello every 10 seconds!\n";
	}, 10)
);

```

Here, this function will run forever every 10 seconds.

### Using already declared functions

[](#using-already-declared-functions)

```
function myFunc() {
	echo "[" . date("h:i:s A") . "] Hello every 10 seconds!\n";
}

$manager->addTask(
	new Task("myFunc", 10)
);

```

Simply pass in the function name as a string.

### Setting maximum number of times to run

[](#setting-maximum-number-of-times-to-run)

```
$manager->addTask(
	(new Task(function() {
		echo "[" . date("h:i:s A") . "] Hello every 10 seconds!\n";
	}, 10))
	->setMaxTimes(5)
);

```

This is done by calling the setMaxTimes function of the Task class which accepts an integer.

In this example, this task will run 5 times total, once every 10 seconds.

### Setting parameters

[](#setting-parameters)

```
$manager->addTask(
	(new Task(function($a, $b) {
		echo "[" . date("h:i:s A") . "] Hello every 10 seconds for 5 times with arguments \"" . $a . "\" and \"" . $b . "\"\n";
	}, 10))
	->setMaxTimes(5)
	->addParameters(array(
		"test1",
		"test2"
	))
);

```

This is done by calling the addParameters function of the Task class which accepts an array.

### Using a random interval range

[](#using-a-random-interval-range)

```
$manager->addTask(
    (new Task(function() {
        echo "[" . date("h:i:s A") . "] Hello every 5-10 seconds!\n";
    }))
	->setRandomIntervalRange(5, 10)
);

```

This task will run every 5 to 10 seconds, a random interval between this range is used each time.

### Running tasks

[](#running-tasks)

The first option is to use:

```
$manager->runTasks();

```

All code after this will not run while there are still tasks remaining.

If you have other tasks to perform, use your own while loop instead

```
while ($manager->runTasksOnce()) {
	// your additional logic
}

```

### Removing tasks

[](#removing-tasks)

Removing tasks is simple. The addTask function returns an integer.

```
$index = $manager->addTask( ... );

```

This can be used to remove the task.

```
$manager->removeTask($index);

```

License
-------

[](#license)

Please read LICENSE.md to learn about what you can and cannot do with this source code.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![weidizhang](https://avatars.githubusercontent.com/u/4133577?v=4)](https://github.com/weidizhang "weidizhang (11 commits)")

### Embed Badge

![Health badge](/badges/weidizhang-php-timed-tasks/health.svg)

```
[![Health](https://phpackages.com/badges/weidizhang-php-timed-tasks/health.svg)](https://phpackages.com/packages/weidizhang-php-timed-tasks)
```

PHPackages © 2026

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