Open hanneskod opened 6 years ago
Needs #160 first..
As of beta-5 we have giroapp.ini
settings anticipating db adapters and pdo support:
; Database driver to use, currently only 'json' is supported
db_driver = json
; Data Source Name, the information required to connect to the database
; Values are driver specific
db_dsn = "%base_dir%/data"
There is now a set of interfaces defining the database layer. Implement these interfaces to add new database drivers. See the Db namespace. Also see the Json driver for an example.
Implementation agnostic tests are in DonorRepositorySpecTrait and ImportHistorySpecTrait. (See the json testsuite for reference.)
Also note that database drivers can be written as plugins using something like
use byrokrat\giroapp\Plugin\PluginInterface;
use byrokrat\giroapp\Plugin\EnvironmentInterface;
return new class implements PluginInterface {
public function loadPlugin(EnvironmentInterface $env): void
{
$env->registerDatabaseDriver(new MyCustomDatabaseDriverFactory);
}
};
The json thing is good during development. As it is easy to inspect. But someting faster is needed in the future. Should probably be a choice between SQLite and MySQL..