formal/access-layer

2.15.0 2024-02-10 14:27 UTC

This package is auto-updated.

Last update: 2024-04-10 14:52:08 UTC


README

Build Status codecov Type Coverage

This a simple abstraction layer on top of builtin \PDO class to offer a minimalist api.

The goal is separate expression of queries and their execution by using immutable structures and eliminating states wherever possible.

Important

you must use vimeo/psalm to make sure you use this library correctly.

Installation

composer require formal/access-layer

Example

use Formal\AccessLayer\{
    Connection\Lazy,
    Connection\PDO,
    Query\SQL,
    Row,
};
use Innmind\Url\Url;
use Innmind\Immutable\Sequence;

$connection = new Lazy(static fn() => PDO::of(Url::of('mysql://user:pwd@127.0.0.1:3306/database_name')));

$rows = $connection(SQL::of('SELECT * FROM `some_table`'));
$rows; // instanceof Sequence<Row>

Documentation

Complete documentation can be found at http://formal-php.github.io/access-layer/.