class Singleton { private static $instance = null; private function __construct() {} public static function getInstance() { if (self::$instance == null) { self::$instance = new Singleton(); } return self::$instance; } public function sayHello() { echo "Hello!"; } } $singleton = Singleton::getInstance(); $singleton->sayHello(); // "Hello!"In this example, the Singleton class has a private static property $instance that holds the unique instance of the class. The constructor is private, which means that it can only be called from within the class itself. The getInstance method checks whether the $instance property has been initialized or not. If it hasn't, it initializes it by creating a new Singleton object. This method is widely used in many different PHP packages and libraries to ensure that only one instance of a class is created. One example of a package that uses getInstance is the Laravel IoC container, which uses it to register and resolve dependencies.