PDODocument
View Source Repo
PDODocument is a PHP library that provides a document database-style view over PostgreSQL and SQLite.
Installing
The library is listed on Packagist as bit-badger/pdo-document
. v1 targets PHP 8.2 and 8.3, while v2 targets PHP 8.4 and up. Run composer require bit-badger/pdo-document
(or add it to your composer.json
manually), and it should select the appropriate version based on the target PHP version of your project.
Using
- Getting Started provides an overview of the library, its configuration, and ensuring that tables and any required indexes exist.
- Basic Usage details document-level retrieval, persistence, and deletion.
- Advanced Usage demonstrates how to use the building blocks provided by this library to write slightly-more complex queries.
Why Would I Choose This?
Document stores have both advantages and disadvantages as compared to relational databases. Absent a unifying standard, relational database vendors have been implementing support for this to varying degrees. The project on which this is based, BitBadger.Documents
, has an examination of “why”, and “why not”, one may choose this.
Why Not (other database with PDO support)?
Of the drivers that PDO supports, PostgreSQL and SQLite have the most mature JSON support. MySQL and MariaDB are very popular choices among PHP developers, but given their divergent paths, their JSON implementations differ - and neither, as of this writing, would fit into a complete document storage model.
Source and Feedback
PDODocument
is an open-source project; this Gitea instance does not (yet) support public registrations. To provide feedback or ask questions about this library, e-mail “daniel” at this domain, or reach out to @daniel@fedi.summershome.org
on the Fediverse (Mastodon) or @Bit_Badger
on Twitter.