https://github.com/formal-php/access-layer
https://github.com/formal-php/access-layer
connection database
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/formal-php/access-layer
- Owner: formal-php
- License: mit
- Created: 2021-02-28T14:17:30.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-09T15:10:25.000Z (about 1 year ago)
- Last Synced: 2025-09-22T03:55:22.087Z (9 months ago)
- Topics: connection, database
- Language: PHP
- Homepage: http://formal-php.github.io/access-layer/
- Size: 1.78 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# access-layer
[](https://github.com/formal-php/access-layer/actions?query=workflow%3ACI)
[](https://codecov.io/gh/formal-php/access-layer)
[](https://shepherd.dev/github/formal-php/access-layer)
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`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly.
## Installation
```sh
composer require formal/access-layer
```
## Example
```php
use Formal\AccessLayer\{
Connection\Lazy,
Connection\PDO,
Query\SQL,
Row,
};
use Innmind\Url\Url;
use Innmind\Immutable\Sequence;
$connection = Lazy::of(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
```
## Documentation
Complete documentation can be found at .