Use Singleton Patern in Slim Framework

as JoeBengalen pointed out, you’ll have to store the instance in session.

something like this:

public static function getInstance() {
	if (true === is_null($_SESSION['SingletonClass'])) {
		echo "getInstance SINGLETON NEW Instance";
		$_SESSION['SingletonClass'] = new self();
	}
	return $_SESSION['SingletonClass'];
}

Since you haven’t provided any specifics of your session handler, I just used the default PHP method, but I’m sure you can adapt it :wink: