berlindb / core

All of the required core code
MIT License
253 stars 27 forks source link

Make BerlinDB configurable #12

Open Luehrsen opened 4 years ago

Luehrsen commented 4 years ago

Right now if you are using BerlinDB via composer you would have to set $db_global in every class that extends Base. This feels mighty redundant.

It would be nice to be able to configure the variables in Base (db_global, prefix) from some outside method in the plugin.

alexstandiford commented 4 years ago

This seems related to: #17

Laravel does this with a config helper function. https://laravel.com/docs/5.3/configuration#accessing-configuration-values

If Berlin is intended to be used outside of WordPress, it might be prudent to make this work in a pattern that is consistent with systems like Laravel.

As mentioned in this Stack Overflow:

The Laravel way is using config files. Create my.php and put it in /config directory and then access constant values globally:

config('my.variable')

Here's an example of my.php:

<?php

return [
    'variable' => 15,
    'some-array' => [1, 2, 5],
];