PHPackages                             integral/flysystem-pdo-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. integral/flysystem-pdo-adapter

ActiveLibrary[File &amp; Storage](/categories/file-storage)

integral/flysystem-pdo-adapter
==============================

PDO adapter for Flysystem file abstraction layer

1.0.4(7y ago)2112.2k9[3 issues](https://github.com/IntegralSoftware/flysystem-pdo-adapter/issues)MITPHP

Since Nov 22Pushed 7y ago2 watchersCompare

[ Source](https://github.com/IntegralSoftware/flysystem-pdo-adapter)[ Packagist](https://packagist.org/packages/integral/flysystem-pdo-adapter)[ RSS](/packages/integral-flysystem-pdo-adapter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Flysystem PDO Database Adapter
==============================

[](#flysystem-pdo-database-adapter)

[![Build Status](https://camo.githubusercontent.com/82b9513d6240a29081e9370c3d56713b6e0653aee3ce147779b070c336d8824a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f496e74656772616c536f6674776172652f666c7973797374656d2d70646f2d616461707465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/IntegralSoftware/flysystem-pdo-adapter)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

PDO database adapter for [Flysystem](https://github.com/thephpleague/flysystem) filesystem abstraction. No additional dependencies, only PDO extension required.

Installation
------------

[](#installation)

```
composer require integral/flysystem-pdo-adapter

```

Database Configuration
----------------------

[](#database-configuration)

At the beginning you have to create a table that will be used to store files.

SQL table schema examples for MySQL, SQLite and PostgreSQL are presented below.

**MySQL**

```
CREATE TABLE files (
  id int(11) NOT NULL AUTO_INCREMENT,
  path varchar(255) NOT NULL,
  type enum('file','dir') NOT NULL,
  contents longblob,
  size int(11) NOT NULL DEFAULT 0,
  mimetype varchar(127),
  timestamp int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (id),
  UNIQUE KEY path_unique (path)
);
```

**SQLite**

```
CREATE TABLE files (
    id INTEGER PRIMARY KEY,
    path TEXT NOT NULL UNIQUE,
    type TEXT NOT NULL,
    contents BLOB,
    size INTEGER NOT NULL DEFAULT 0,
    mimetype TEXT,
    timestamp INTEGER NOT NULL DEFAULT 0
)
```

**PostgreSQL**

```
CREATE TABLE public.files (
  id serial NOT NULL,
  path varchar(255) NOT NULL,
  type varchar(4) NOT NULL,
  contents bytea,
  size integer NOT NULL DEFAULT 0,
  mimetype varchar(127),
  "timestamp" integer NOT NULL DEFAULT 0,
  is_compressed boolean NOT NULL DEFAULT true,
  update_ts timestamp(0) with time zone DEFAULT NOW(),
  CONSTRAINT files_pkey PRIMARY KEY (id),
  CONSTRAINT type_check CHECK (type='dir' or type='file'),
  CONSTRAINT path_unique UNIQUE (path)
);
```

Usage
-----

[](#usage)

Create an adapter by passing a valid `PDO` object and table name as constructor arguments:

**MySQL**

```
// http://php.net/manual/pl/ref.pdo-mysql.connection.php
$pdo = new PDO('mysql:host=hostname;dbname=database_name', 'username', 'password');
$adapter = new PDOAdapter($pdo, 'files');
```

**SQLite**

```
// http://php.net/manual/pl/ref.pdo-sqlite.connection.php
$pdo = new PDO('sqlite:/absolute/path/to/database.sqlite');
$adapter = new PDOAdapter($pdo, 'files');
```

**PostgreSQL**

```
// http://php.net/manual/pl/ref.pdo-pgsql.php
$pdo = new PDO('pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass');
$adapter = new PDOAdapter($pdo, 'public.files');
```

Then simply pass the created adapter to `\League\Flysystem\Filesystem`:

```
$filesystem = new Filesystem($adapter);
```

Done! At this point the `$filesystem` is ready to use.

Note
----

[](#note)

This implementation emulates a tree structured filesystem, therefore some of the operations (like renaming or deleting a folder) produce quite a lot of database queries, which may result in a poor performance for some scenarios.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 52.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~296 days

Total

5

Last Release

2637d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59d0420c69bdcb56f0009e77fd41ad3e188d5522206dd700e897b748072b3b7d?d=identicon)[zaak](/maintainers/zaak)

---

Top Contributors

[![zaak](https://avatars.githubusercontent.com/u/803299?v=4)](https://github.com/zaak "zaak (9 commits)")[![xlii-chl](https://avatars.githubusercontent.com/u/42654312?v=4)](https://github.com/xlii-chl "xlii-chl (5 commits)")[![bstoots](https://avatars.githubusercontent.com/u/5334637?v=4)](https://github.com/bstoots "bstoots (2 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/integral-flysystem-pdo-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/integral-flysystem-pdo-adapter/health.svg)](https://phpackages.com/packages/integral-flysystem-pdo-adapter)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M788](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M87](/packages/league-flysystem-bundle)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
