PHP code example of hirokws / strivejobs

1. Go to this page and download the library: Download hirokws/strivejobs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hirokws / strivejobs example snippets



use StriveJobs\StriveJobsInterface;
use StriveJobs\BaseJobClass;

class BulkMail extends BaseJobClass implements StriveJobsInterface
{

    public function getDescription()
    {
        return 'このジョブクラスの説明'; // listコマンドで標示
    }

    public function getName()
    {
        return 'BulkMail'; // ジョブの名前
    }

    public function doRegistered( $data ) // do+ステータスのメソッドが呼び出される
    {
        $this->message = 'おめでとう!'; // 表示メッセージの設定
        $this->setTerminated(); // set+ステータスで、ステータス変更
        return true; // 呼び出し元に、実行の成功を通知
    }

    public function doTerminated( $data ) // ステータスterminatedはジョブ終了
    {
        $this->message = '残念!切腹!';
        $this->harakiri(); // この実行ジョブを削除
        return true;
    }

    public function doDefault( $data ) // メソッド未定義の場合はこれが呼び出される
    {
        $this->message = '残念!'; // 呼び出し元にメッセージを渡す
        return false; // 呼び出し元に、実行の失敗を通知
    }