PHPackages                             gaxz/yii2-cron-manager - 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. gaxz/yii2-cron-manager

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

gaxz/yii2-cron-manager
======================

Simple and flexible background tasks manager module for Yii2 framework

v1.0.3(6y ago)0287↓50%2[1 issues](https://github.com/gaxz/yii2-cron-manager/issues)[2 PRs](https://github.com/gaxz/yii2-cron-manager/pulls)BSD-3-ClausePHP

Since Apr 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gaxz/yii2-cron-manager)[ Packagist](https://packagist.org/packages/gaxz/yii2-cron-manager)[ RSS](/packages/gaxz-yii2-cron-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Cron Manager module for Yii2 framework
======================================

[](#cron-manager-module-for-yii2-framework)

This is a simple and flexible module for creating\\updating background tasks of cron application. It is designed to work with yii2 console controllers and description provides some advice to work with them.

Installation
============

[](#installation)

Via composer

```
composer require --prefer-dist gaxz/yii2-cron-manager

```

or add to your composer.json

```
"gaxz/yii2-cron-manager": "*"

```

and

```
composer install

```

Add the code below to your web and console config files:

```
'modules' => [
    'crontab' => [
    	'class' => 'gaxz\crontab\Module'
    ],
]

```

And finally

```
php yii migrate --migrationNamespaces=gaxz\\crontab\\migrations

```

To apply migrations via docker you might need to replace double backslashes with single.

Also make sure that cron is installed and running.

Configuration
=============

[](#configuration)

Module requires a list of routes to yii2 console controllers. The list is used in gui to set up background tasks and form crontab lines. You can specify this by passing the controller classname with namespace into config file:

```
'source' => 'app\commands\HelloController'

```

or an array

```
'source' => [
    'console\controllers\EmailController',
    'console\controllers\UserController',
],

```

Module will parse controllers and form list of routes. Excluding actions from list if needed:

```
'exclude' => [
	'/email/send'
],

```

or you can specify routes manually

```
'routes' => [
    '/console/email/send',
    '/console/user/proccess-order'
]

```

**It is important to add "/" at the start to provide an absolute route.****Don't forget to apply changes to both console and web configuration files.**

Usage
=====

[](#usage)

Now you can manage background tasks in the module section of your application.

1. Create Cron Task
2. Add cron expression to schedule field
3. Select a route from list

If your background task is using parameters you can add them as a json string in gui, then pass to controller action and decode.

```
public function actionTest($params)
{
    $params = json_decode($params, true);
    print $params['message'] . PHP_EOL;
    return ExitCode::OK;
}

```

It is important to use PHP\_EOL to write readable output to logs. Also module is using ExitCode class to normalize return values and it's recommended to design your actions accordingly to ExitCode constants. You can use them in exceptions as well:

```
if (empty($model)) {
    throw new Exception('Unable to find model', ExitCode::DATAERR);
}

```

**You don't need to try-catch exceptions since module is doing it by itself.**This will form readable logs that are comfortable to support and search through.

Will be useful to check crontab file of php user to check if everything works correctly.

```
crontab -e -u www-data

```

Advanced configuration
======================

[](#advanced-configuration)

**Warning! Before you update settings that change crontab line (e.g phpBin, yiiBootstrapAlias, outputSetting), disable all of your active cron tasks.**

**Duplicating output to a file or STDOUT\\STDERR:**

```
'modules' => [
    'crontab' => [
    	'class' => 'gaxz\crontab\Module'
    	...
        'outputSetting' => '>> /var/log/app.log'
        ...
    ],
]

```

will form:

```
php yii /crontab/exec 1 >> /var/log/app.log

```

**Setting path to php binary file manually:**

```
'phpBin' => '/usr/bin/php'

```

**Writing configs of crontab file:**

```
'headLines' => [
    'SHELL=/bin/sh',
    'PATH=/usr/bin:/usr/sbin',
],

```

**Setting crontab username***This will work only in case PHP script is running from privileged user (e.g. 'root')*

```
'crontabUsername' => 'www-data',

```

**Setting path to yii bootstrap file**

```
'yiiBootstrapAlias' => '@app/yii'

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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.

###  Release Activity

Cadence

Every ~9 days

Total

4

Last Release

2197d ago

### Community

Maintainers

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

---

Top Contributors

[![gaxz](https://avatars.githubusercontent.com/u/17141020?v=4)](https://github.com/gaxz "gaxz (2 commits)")

---

Tags

cronmanageryii2modulebackgroundTaskscrontab

### Embed Badge

![Health badge](/badges/gaxz-yii2-cron-manager/health.svg)

```
[![Health](https://phpackages.com/badges/gaxz-yii2-cron-manager/health.svg)](https://phpackages.com/packages/gaxz-yii2-cron-manager)
```

###  Alternatives

[branchonline/yii2-lightbox

Lightbox widget for Yii2

13139.0k1](/packages/branchonline-yii2-lightbox)[akiraz2/yii2-ticket-support

Yii2 Support Ticket Module, easy, flexible, fast

611.7k](/packages/akiraz2-yii2-ticket-support)

PHPackages © 2026

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