In the slim-skeleton / slim 4 the dependencies looks like this where it just returns value. Is something like this possible or do I need to retype my dependencies page to add each one individually to the container as opposed to just returning just a logger?
return function (ContainerBuilder $containerBuilder) {
$containerBuilder->addDefinitions([
LoggerInterface::class => function (ContainerInterface $c) {
$settings = $c->get(‘settings’);
The question is: Do you really want to be able to exchange the connection even though you only use PDO?? If not, you may not need a generic database interface.
If yes, here is a PDO “inspired” connection interface:
interface ConnectionInterface
{
public function beginTransaction(): bool;
public function commit(): bool;
public function errorCode(): string;
public function errorInfo(): array;
public function exec(string $statement): int;
public function inTransaction(): bool;
public function lastInsertId(string $name = null): string;
public function prepare(string $statement, array $driverOptions = []): PDOStatement;
public function query(string $statement): PDOStatement;
public function quote(string $string, int $parameterType = PDO::PARAM_STR): string;
public function rollBack(): bool;
}
This interface is still not perfect, because the PDOStatement is not abstracted away. This would require another interface like a StatementInterface etc. You see, it’s getting more and more complex