Skip to content

Getting started

This library is designed to eliminate state wherever possible when dealing with a database connection.

The result is an api that consist of only one method on the connection (__invoke) and one kind of argument (Query). Both can easily be extended through composition.

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

Installation

composer require formal/access-layer

Basic usage

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

$connection = 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>