PHPackages                             webtoolsnz/yii2-scheduler - 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. webtoolsnz/yii2-scheduler

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

webtoolsnz/yii2-scheduler
=========================

A scheduled task runner for Yii2 applications

0.1.19(5y ago)1881.1k—6.4%14[4 issues](https://github.com/webtoolsnz/yii2-scheduler/issues)proprietaryPHPCI failing

Since Jun 5Pushed 5y ago13 watchersCompare

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

READMEChangelog (10)Dependencies (9)Versions (27)Used By (0)

yii2-scheduler
==============

[](#yii2-scheduler)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/be3a6186232a4a4ab15549276ce20a7627365cff2b3a3e05439a7034a31273d1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776562746f6f6c736e7a2f796969322d7363686564756c65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/webtoolsnz/yii2-scheduler)[![Coverage Status](https://camo.githubusercontent.com/1f7086a5fe7599582066dd5bca1bd3b358901ca3ab7124ef67952c1b350a8c72/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f776562746f6f6c736e7a2f796969322d7363686564756c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webtoolsnz/yii2-scheduler/code-structure)[![Quality Score](https://camo.githubusercontent.com/e3afc72caf2799cd6e450d9c23f57250b4b47718da0812a3260c151acf14f39c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776562746f6f6c736e7a2f796969322d7363686564756c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webtoolsnz/yii2-scheduler)

A scheduled task manager for yii2

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Install using the following command.

```
$ composer require webtoolsnz/yii2-scheduler
```

Now that the package has been installed you need to configure the module in your application

The `config/console.php` file should be updated to reflect the changes below

```
    'bootstrap' => ['log', 'scheduler'],
    'modules' => [
        'scheduler' => ['class' => 'webtoolsnz\scheduler\Module'],
    ],
    'components' => [
        'errorHandler' => [
            'class' => 'webtoolsnz\scheduler\ErrorHandler'
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\EmailTarget',
                    'mailer' =>'mailer',
                    'levels' => ['error', 'warning'],
                    'message' => [
                        'to' => ['admin@example.com'],
                        'from' => [$params['adminEmail']],
                        'subject' => 'Scheduler Error - ####SERVERNAME####'
                    ],
                    'except' => [
                    ],
                ],
            ],
        ],
    ]
```

also add this to the top of your `config/console.php` file

```
\yii\base\Event::on(
    \webtoolsnz\scheduler\console\SchedulerController::className(),
    \webtoolsnz\scheduler\events\SchedulerEvent::EVENT_AFTER_RUN,
    function ($event) {
        if (!$event->success) {
            foreach($event->exceptions as $exception) {
                throw $exception;
            }
        }
    }
);
```

To implement the GUI for scheduler also add the following to your `config/web.php`

```
    'bootstrap' => ['log', 'scheduler'],
    'modules' => [
        'scheduler' => ['class' => 'webtoolsnz\scheduler\Module'],
    ],
```

After the configuration files have been updated, a `tasks` directory will need to be created in the root of your project.

Run the database migrations, which will create the necessary tables for `scheduler`

```
php yii migrate up --migrationPath=vendor/webtoolsnz/yii2-scheduler/src/migrations
```

Add a controller

```
