1. Go to this page and download the library: Download rasuvaeff/context 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/ */
$request->assertActive(); // throws ContextCancelledException / ContextExpiredException
$request->isTerminated(); // cancelled or expired
$request->isCancelled(); // explicit cancellation
$request->isExpired(); // deadline passed
$request->remainingMs(); // null without a deadline; >= 1.0 while active, 0.0 once expired
$unsubscribe = $request->onTerminate(static function (TerminationCause $cause): void {
// release a resource owned by this operation
});
$unsubscribe(); // the resource was released early: drop the listener
$requestController->cancel($reason); // $reason becomes the exception's previous
// sender: an HTTP header or a queue message attribute
$headers['X-Request-Timeout-Ms'] = (string) (int) $context->remainingMs();
// receiver: never longer than its own limit
[$context] = Context::background()->withTimeout(min($limitSeconds, $headerMs / 1000));
$clock = new FakeTimeSource(); // your TimeSource returning nowNs()
[$context] = Context::background($clock)->withTimeout(1.0);
$clock->advanceNs(2_000_000_000);
$context->isExpired(); // true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.