PHPackages                             simettric/wp-simple-orm - 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. simettric/wp-simple-orm

ActiveLibrary

simettric/wp-simple-orm
=======================

Simple ORM for WordPress custom post types and the relations relations between them

1190PHP

Since Mar 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Simettric/WPSimpleORM)[ Packagist](https://packagist.org/packages/simettric/wp-simple-orm)[ RSS](/packages/simettric-wp-simple-orm/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WPSimpleORM
===========

[](#wpsimpleorm)

Not ready for production use yet

USAGE
=====

[](#usage)

### Simple entity

[](#simple-entity)

```
class Person extends AbstractEntity
{

    function getName()
    {
        $this->getTitle();
    }

    function getAddress()
    {
        return $this->get('address');
    }

    function setAddress($address)
    {
        $this->set('address', $address);
    }

    function getPhone()
    {
        return $this->get('phone');
    }

    function setPhone($phone)
    {
        $this->set('phone', $phone);
    }

    static public function getEntityPostType()
    {
        return 'person';
    }

    public function configure()
    {

    }

}

$post = get_post(1);

$person = new Person($post);
$person->setAddress("13 Rue del Percebe");

echo $person->getId();
echo $person->getName();
echo $person->getAddress();

```

### Relationships between entities

[](#relationships-between-entities)

```
    class Person extends AbstractEntity
    {

        function getName()
        {
            $this->getTitle();
        }

        function getVideos($limit=null)
        {
            return $this->repository->getRelatedItems($this, Video::class, 'ID', "DESC", $limit);
        }

        function addVideo(Video $item)
        {
            return $this->repository->addRelatedTo($this, $item);
        }

        function removeVideo(Video $item)
        {
            return $this->repository->removeRelatedItem($this, $item);
        }

        static public function getEntityPostType()
        {
            return 'person';
        }

        public function configure()
        {
            $this->configureRelation(Video::class, static::ONE_TO_MANY);
        }

    }

    class Video extends AbstractEntity
    {

        function getName()
        {
            $this->getTitle();
        }

        function getPerson()
        {
            return $this->repository->getRelatedItem($this, Video::class);
        }

        function setPerson(Person $item)
        {
            return $this->repository->addRelatedTo($item, $this);
        }

        function removePerson(Person $item)
        {
            return $this->repository->removeRelatedItem($this, $item);
        }

        static public function getEntityPostType()
        {
            return 'video';
        }

        public function configure()
        {
            $this->configureInverseRelation(Person::class, static::MANY_TO_ONE);
        }

    }

    $video  = new Video($video_post);
    $person = new Person($post);

    $person->addVideo($video);

    foreach($person->getVideos() as $video)
    {
        echo $video->getTitle();
    }

    $person->removeVideo($video);

    // also, you can operate in the reverse way as well

    $video->setPerson($person);

    echo $video->getPerson();

    $video->removePerson();

```

### Show the relationships meta box and admin page in wp-admin

[](#show-the-relationships-meta-box-and-admin-page-in-wp-admin)

```
    //functions.php or in your plugin (outside of any hook)

    $relationsMenu = new EntityRelationsHooks(Person::class);
    $relationsMenu->registerHooks();

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

---

Top Contributors

[![asiermarques](https://avatars.githubusercontent.com/u/149459?v=4)](https://github.com/asiermarques "asiermarques (27 commits)")

### Embed Badge

![Health badge](/badges/simettric-wp-simple-orm/health.svg)

```
[![Health](https://phpackages.com/badges/simettric-wp-simple-orm/health.svg)](https://phpackages.com/packages/simettric-wp-simple-orm)
```

PHPackages © 2026

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