PHP code example of nullform / app-timer

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

    

nullform / app-timer example snippets


use Nullform\AppTimer;

$timer = new AppTimer\Timer("New timer");

$timer->start("First interval");
// Some code...
$interval = $timer->stop(); // Instance of Interval

$timer->start("Second interval");
// Some code...
$duration = $timer->stop()->duration; // float

$report = $timer->report(); // Instance of Report

$timer->start("First interval"); // Parent interval

$timer->start("First nested interval");
// Some code...
$timet->stop(); // Stop first nested interval

$timer->start("Second nested interval");
// Some code...
$timet->stop(); // Stop second nested interval

$timer->stop(); // Stop parent interval

$report = $timer->report(); // Instance of Report

$timer = new AppTimer\Timer("New timer", ['Size' => "XXL"]);
$timer->start("New interval", ['Color' => "Red"]);

// Create new timer
$timer = new AppTimer\Timer("New timer");

// Report file options
$timer->report_filename = "AppTimerReport.log";
$timer->report_dir = dirname(__FILE__);
$timer->report_file_append = true;

$timer->start("New interval");
// ...
$timer->stop();

// Create report
$report = $timer->report(); // Instance of Report

$report_json = $report->toJSON();
$report_string = $report->toString();