How does the Registry pattern compare to using static container classes for storing objects in PHP applications?

The Registry pattern provides a centralized way to store and access objects throughout an application, allowing for more flexibility and control over object management compared to using static container classes. The Registry pattern can help avoid tight coupling between classes and simplify the process of sharing objects between different parts of the application.

class Registry {
    private static $objects = [];

    public static function set($key, $value) {
        self::$objects[$key] = $value;
    }

    public static function get($key) {
        return self::$objects[$key];
    }
}

// Usage example
Registry::set('db', new Database());
$db = Registry::get('db');