silvanus / ouroboros-orm
Simple ORM for custom DB tables in WP
Requires (Dev)
- giacocorsiglia/wordpress-stubs: ^5.1
- infection/infection: ^0.18.2
- php-stubs/wordpress-globals: ^0.2.0
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2023-08-15 06:43:18 UTC
README
Ouroboros was originally written when I still worked more with PHP / WP. The basic functionalities were finished and worked, but never really finalized or tested in a real project.
There is a good chance it all works, so feel free to look around or fork it. Still, be warned: do not use for purposes other than curiosity.
Ouroboros ORM
Create and use custom WP database tables in ORM-like way. Inspired by tools like Eloquent ORM and Objection.js.
Features
- Schemas: create custom tables for your data.
- Migrations: run your schemas up / down with CLI commands.
- Models: create and use data with model entitites.
- REST API: easily use your Ouroboros data from WP REST endpoints.
Motivation
WP database structure is less-than-optimal. When you find yourself creating custom tables in WordPress, you should probably consider using some other platform.
However, we can't always decide what tools we use for a project. The way WordPress supports creating new tables or using data in them is very bare bones. Ouroboros aims to make working with custom tables more streamlined and enjoyable.
Usage
- See "examples" folder
- See "tests" and "src" to get general idea.
Install
Via Composer:
composer require silvanus/ouroboros-orm
To use autoloading mechanism, you must include vendor/autoload.php
file in your code.
Whats in the name?
For those who speak north germanic languages, "orm" means snake or a worm. Therefore I've always associated "ORM" systems with snakes. "Ouroboros" is a snake biting it's own tail, which is fitting enough description for writing an ORM for WordPress.