PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of Sergii Pryz   PHP Process Manager   Example.php   Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Process Manager
Execute PHP code within time and memory limits
Author: By
Last change: Updated Autoload and changed folder structure.
Date: 10 years ago
Size: 729 bytes
 

Contents

Class file image Download
<?php
/**
 * =====================================
 * Example of usage ProcessManager
 * =====================================
 */

namespace ProcessManager;

// ProcessManager Autoload
require_once ('./src/Autoload.php');

/**
 * Lets we have process
 */
class ExampleProcess implements Process\ProcessInterface
{
    private
$iteration = 1;
   
    public function
run()
    {
        echo
' === Iteration #'.$this->iteration++.' successfully finished === '."\n";
       
sleep(5);
    }
}

// 1. Identify time
$time = microtime(true);

// 2. Create Process
$process = new ExampleProcess();

// 3. Create Manager
$manager = new Manager();

// 4. Start Process
$manager->setTime($time)
    ->
startProcess($process);