If we truly want to make BerlinDB compatible with systems outside of WordPress, it may be prudent to make a change to how Base::get_db() works. Not all systems utilize a DB global in the way WordPress does, and few classes actually have the exact same methods as $wpdb.
It may be best to consider creating an interface that allows BerlinDB to interact with other database systems dynamically. This could implement the methods that Berlin calls directly from $wpdb. This would allow people to translate their system into Berlin's system.
Instead of having BerlinDB look for a global, perhaps it would fetch the specified instance, check if it implements, and use it.
This would require an extra file to make WPDB work with it, which is kind-of a bummer, but I think that's a small price to-pay. Since 2.0 is compatible with Composer, this interface and implementation could be somehow added as a composer package. This would make installing a WP-compatible version of Berlin as simple as running composer require berlindb/wordpress, or something similar.
Further, I can see this pattern being used in other places, such as an object cache implementation.
If we truly want to make BerlinDB compatible with systems outside of WordPress, it may be prudent to make a change to how
Base::get_db()
works. Not all systems utilize a DB global in the way WordPress does, and few classes actually have the exact same methods as$wpdb
.It may be best to consider creating an interface that allows BerlinDB to interact with other database systems dynamically. This could implement the methods that Berlin calls directly from
$wpdb
. This would allow people to translate their system into Berlin's system.Instead of having BerlinDB look for a global, perhaps it would fetch the specified instance, check if it implements, and use it.
This would require an extra file to make WPDB work with it, which is kind-of a bummer, but I think that's a small price to-pay. Since 2.0 is compatible with Composer, this interface and implementation could be somehow added as a composer package. This would make installing a WP-compatible version of Berlin as simple as running
composer require berlindb/wordpress
, or something similar.Further, I can see this pattern being used in other places, such as an object cache implementation.