class Database { private static $instance; private function __construct() {} public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; } public function query($sql) { // code to execute the SQL query } }
class Config { private static $instance; private function __construct() {} public static function get_instance() { if (!self::$instance) { self::$instance = new self(); // code to load configuration data from a file or database } return self::$instance; } public function get($key) { // code to get a specific configuration value } }In this example, we have a configuration class with a private constructor and a static $instance property. The get_instance() method creates a new instance of the class if one doesn't already exist, otherwise it returns the existing instance. The get() method can then be called on the instance to retrieve a specific configuration value. Package/Library: It could be a custom package/library created by the developer or could be using popular config library like DotEnv.