PHP code example of robertology / todo_or_die

1. Go to this page and download the library: Download robertology/todo_or_die 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/ */

    

robertology / todo_or_die example snippets


new Todo($todo_message, $check_to_die);

new Todo($todo_message, $check_to_alert, $callable_for_alerting);

(new Todo($todo_message, $check_to_die))
  ->alertIf($check_to_alert, $callable_for_alerting);

putenv('TODOORDIE_SKIP_DIE=1');

// Once per day
putenv('TODOORDIE_ALERT_THRESHOLD=86400');

// Disabled (alert every time)
putenv('TODOORDIE_ALERT_THRESHOLD=0');

use Robertology\TodoOrDie\Todo;
use Robertology\TodoOrDie\Check\Dates as DateCheck;

// Die only
new Todo(
  'Remove after the old jobs have attritioned out',
  new DateCheck(strtotime('1 jan 2024'))
);

// Alert only
// Note the use of fromString() which gives the same result as strtotime() above
new Todo(
  'Remove after the old jobs have attritioned out',
  DateCheck::fromString('1 jan 2024'),
  [$logger, 'warning']
);

// A couple Alerts before we Die
(new Todo('Remove after the old jobs have attritioned out', DateCheck::fromString('1 jan 2024')))
  ->alertIf(DateCheck::fromString('22 dec 2023'), [$logger, 'warning'])
  ->alertIf(time() >= strtotime('27 dec 2023'), $my_slack_callable);
//           ^ the constructor and alertIf() can take a Check object or boolean