PHPackages                             hugsbrugs/php-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hugsbrugs/php-tasks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hugsbrugs/php-tasks
===================

PHP Tasks Utilities

014PHP

Since Jan 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hugsbrugs/php-tasks)[ Packagist](https://packagist.org/packages/hugsbrugs/php-tasks)[ RSS](/packages/hugsbrugs-php-tasks/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-tasks
=========

[](#php-tasks)

This librairy provides utilities function to manage tasks processing

[![Build Status](https://camo.githubusercontent.com/14f1a6fad8891e0aae4103f25f24535d0f6a7b1f26e9c9f57847148b880df118/68747470733a2f2f7472617669732d63692e6f72672f6875677362727567732f7068702d7461736b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hugsbrugs/php-tasks)[![Coverage Status](https://camo.githubusercontent.com/2934ba1a9b7c5933b634e6dd54998cf91fbe52fc61c662c2c7e2782450106b3f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6875677362727567732f7068702d7461736b732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hugsbrugs/php-tasks?branch=master)

Install
-------

[](#install)

Install package with composer

```
composer require hugsbrugs/php-tasks

```

In your PHP code, load library

```
require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Tasks\Tasks as Tasks;
```

### Edit config.ini

[](#edit-configini)

Tasks can be stored in 3 differents ways : in file, in MySql or SqlLite database. Fill in appropriate section in config file. You can tweak \[task\_manager\] sections (in seconds) depending on your tasks manager behavior and your server capacities

```
[task_store]
TASK_STORE_METHOD = 'file';'file'|'mysql'|'sqllite'

[task_store_file]
TASK_STORE_FILE = '/var/www/my-project/tasks.json'

[task_tmp_file]
TASK_TMP_FILE = '/tmp'

[task_store_mysql]
TASK_STORE_MYSQL_USER = 'username'
TASK_STORE_MYSQL_PASS = 'password'
TASK_STORE_MYSQL_HOST = 'localhost'
TASK_STORE_MYSQL_PORT = 3306
TASK_STORE_MYSQL_DB = 'database_name'
TASK_STORE_MYSQL_TABLE = 'tasks_table_name'
TASK_STORE_MYSQL_ENV = 'dev';'dev'|'prod'

[task_store_sqllite]
TASK_STORE_SQLLITE_FILE = '/var/www/my-project/tasks.sqllite.db'
TASK_STORE_SQLLITE_USER = ''
TASK_STORE_SQLLITE_PASS = ''
TASK_STORE_SQLLITE_DB = 'database_name'
TASK_STORE_SQLLITE_TABLE = 'tasks_table_name'
TASK_STORE_MYSQL_ENV = 'dev';'dev'|'prod'

[task_manager]
LOAD_PENDING_TASKS_DELAY = 15
CHECK_RUNNING_PIDS_DELAY = 4
PROCESS_TASKS_DELAY = 4

```

### Edit process\_tasks.php

[](#edit-process_tasksphp)

In this file, you will define your different tasks names and how many threads can run concurrently for each task.

```
# Load config.ini file
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/../vendor/autoload.php';

use Hug\Tasks\TaskStore as TaskStore;
use Hug\Tasks\TaskManager as TaskManager;
use Hug\Tasks\Task as Task;

# Define task_name => max threads
$tasks_threads = [
    'export' => 1,
    'download' => 1,
    'delete' => 1,
    'extract' => 5,
    'check_availability' => 5,
    'check_metrics' => 5
];

# Create Task Store (see config.ini for params)
$task_store = TaskStore::getInstance();

# Start Task Manager
$TaskManager = new TaskManager($tasks_threads, $task_store);
```

Run The task manager on command line for testing purposes

```
php process_tasks.php
```

In production mode, use a tool like supervisord to always run your task manager

```
[program:phptasks]
command=bash -c "ulimit -n 10000; exec /usr/bin/php /var/www/my-project/process_tasks.php"
process_name=phptasks
numprocs=1
autostart=true
autorestart=true
user=www-data
stdout_logfile=/var/log/supervisor/supervisor-phptasks-info.log
stdout_logfile_maxbytes=1MB
stderr_logfile=/var/log/supervisor/supervisor-phptasks-error.log
stderr_logfile_maxbytes=1MB

```

### Add Tasks add\_task.php

[](#add-tasks-add_taskphp)

In another php file, create a task and add it to the task store.

```
# Create Task Store (see config.ini for params)
$task_store = TaskStore::getInstance();

# Create a Task
$task = new Task(1, null, 'export', 'ls -lsa', ['project_id' => 34]);

# Save Task
$task_store->save($task);
```

Task status can be one of following : 'pending', 'running', 'closed', 'failed'

Author
------

[](#author)

Hugo Maugey [Webmaster](https://hugo.maugey.fr/webmaster) | [Consultant SEO](https://hugo.maugey.fr/consultant-seo) | [Fullstack developer](https://hugo.maugey.fr/developpeur-web)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

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.

### Community

Maintainers

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

---

Top Contributors

[![hugsbrugs](https://avatars.githubusercontent.com/u/4385090?v=4)](https://github.com/hugsbrugs "hugsbrugs (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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