PHP code example of autoframe / process-control

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

    

autoframe / process-control example snippets


/** Concrete implementation that uses the php temporary folder to store the lock */
namespace Autoframe\Process\Control\Lock;
class AfrLockFileClass implements AfrLockInterface
...
interface AfrLockInterface
{
    /** Check if the lock is in place */
    public function isLocked(): bool;

    /** Creates a new lock or fails */
    public function obtainLock(): bool;

    /** Returns false if lock is in place and the lock file can't be closed
     *  Returns true if there is no lock in place or operation was successfully made */
    public function releaseLock(): bool;

    /** Returns Process ID for the lock thread or zero if other case */
    public function getLockPid(): int;
}

/** Concrete implementation for create (spawn) worker process in background */
namespace Autoframe\Process\Control\Worker\Background;
class AfrBackgroundWorkerClass implements AfrBackgroundWorkerInterface
...
interface AfrBackgroundWorkerInterface
{
    /** Returns /usr/bin/php or C:\xampp\php\php.exe or php */
    public static function getPhpBin(): string;

    /** Calls: php $execFileArgs > /dev/null & or widows equivalent start /B */
    public static function execWithArgs(string $execFileArgs): void;
}