Download the PHP package webtoolsnz/yii2-scheduler without Composer

On this page you can find all versions of the php package webtoolsnz/yii2-scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-scheduler

yii2-scheduler

Build Status Coverage Status Quality Score

A scheduled task manager for yii2

Installation

The preferred way to install this extension is through composer.

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' => ['[email protected]'],
                        '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

Example Task

You can now create your first task using scheduler, create the file AlphabetTask.php inside the tasks directory in your project root.

Paste the below code into your task:

The above code defines a simple task that runs at the start of every hour, and prints the alphabet.

The $schedule property of this class defines how often the task will run, these are simply Cron Expression

Running the tasks

Scheduler provides an intuitive CLI for executing tasks, below are some examples

In order to have your tasks run automatically simply setup a crontab like so

Events & Errors

Events are thrown before and running individual tasks as well as at a global level for multiple tasks

Task Level

or at the global level, to throw errors in /yii

You could throw the exceptions at the task level, however this will prevent further tasks from running.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of yii2-scheduler with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ^2.0.9
mtdowling/cron-expression Version ~1.0
webtoolsnz/yii2-widgets Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webtoolsnz/yii2-scheduler contains the following files

Loading the files please wait ....