Skip to content

Ensure deferred execution of code, even in case of fatal error.

Notifications You must be signed in to change notification settings

php-protein/deferred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Protein | Deferred

Ensure deferred execution of code, even in case of fatal error.

Install


composer require proteins/deferred

Require the class via :

use Proteins\Deferred;

Run code at function end or in case of error.


The passed callback will be queued for execution on Deferred object destruction.

function duel(){
	echo "A: I will have the last word!\n";

	echo "B: Wanna bet?\n";

	$defer_B_last_word = new Deferred(function(){
		echo "B: Haha! Gotcha!\n";
	});
	
	die("A: I WIN!\n"); // Hahaha!

	echo "B: WUT?\n";
}

duel();
A: I will have the last word!
B: Wanna bet?
A: I WIN!
B: Haha! Gotcha!

About

Ensure deferred execution of code, even in case of fatal error.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages