Data source
Avocado DataSource class
If you want to use a database connection inside of framework you should define a config class with a DataSource implementation.
Avocado in base provides two dependencies that implements a Driver class:
hubert/avocado-postgresql-driver-> to use with PSQLhubert/avocado-mysql-driver-> to use with MySQL and MariaDB
Example
php
#[Configuration]
class DataSourceConfiguration {
public function __construct() {}
#[Leaf]
public function dataSource(): DataSource {
return (new DataSourceBuilder())
->server("...") // server ip or host
->databaseName("...") // db name
->username("...") // db user
->password("...") // db pass
->port("...") // db port
->charset("...") // charset valid for database ex `utf-8`
->driver(PostgreSQLDriver::class) // implementation of `Driver` class
->build();
}
}If you want to implements your own implementation to provide a new data source check Own implementation section