PHP code example of icewind / patcher

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

    

icewind / patcher example snippets


use Icewind\Patcher\Patcher;

$patcher = new Patcher();
$patcher->patchMethod('time', function () {
    return 100;
});
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();


use Icewind\Patcher\Patcher;

$patcher = new Patcher();
$patcher->patchMethod('time', function ($method, $arguments, $original) {
    $time = $original();
    error_log("Time: $time");
    return $time;
});
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();


use Icewind\Patcher\Patcher;

class DummyDateTime extends DateTime {
	public function __construct() {
		parent::__construct("1970-01-01 00:00:00 UTC");
	}
}

$patcher = new Patcher();
$patcher->patchClass('\DateTime', '\DummyDateTime');
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();