PHPackages                             awoyotoyin/zfe-base - 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. [Framework](/categories/framework)
4. /
5. awoyotoyin/zfe-base

ActiveLibrary[Framework](/categories/framework)

awoyotoyin/zfe-base
===================

Base Library for Zend Expressive/Doctrine ORM

1.1.1(8y ago)128MITPHPPHP ^5.6 || ^7.0

Since Apr 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/AwoyoToyin/zfe-base)[ Packagist](https://packagist.org/packages/awoyotoyin/zfe-base)[ Docs](https://www.github.com/awoyotoyin/zfe-base)[ RSS](/packages/awoyotoyin-zfe-base/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (4)Used By (0)

Doctrine ORM DB Abstraction
===========================

[](#doctrine-orm-db-abstraction)

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

[](#installation)

```
$ composer require awoyotoyin/zfe-base "~1.0.0"
```

### Register the module

[](#register-the-module)

> ### Zend Expressive
>
> [](#zend-expressive)
>
> ```
> use Zfe\Common\ConfigProvider as CommonConfigProvider;
>
> $aggregator = new ConfigAggregator([
>     ...
>     CommonConfigProvider::class,
>     ...
> ], $cacheConfig['config_cache_path']);
> ```

Usage
-----

[](#usage)

### Entity Class

[](#entity-class)

```
title;
    }

    /**
     * Set the value of title
     *
     * @param  string  $title
     * @return self
     */
    public function setTitle(string $title): self
    {
        $this->title = $title;
        return $this;
    }
}
```

Your Entity class should extend `Zfe\Common\Entity\AbstractEntity`. The `Zfe\Common\Entity\AbstractEntity` class defines the Id, CreatedAt and UpdatedAt attributes for your entity. If you are extending from this class, your Entity class must define the lifecycle callbacks as it is required for both the CreatedAt and UpdatedAt attributes.

The `Zfe\Common\Entity\AbstractEntity` class also exposes a `exchangeArray` method that takes an array as it's only argument and set your entity members from the array members.

```
Example:
$data = [
    'title' => 'Some Title'
];

$post = new Post();
$post->exchangeArray($data);
$post->getTitle(); // Some Title

```

### Provider Class

[](#provider-class)

The Provider performs all database related operations hence, this class would mostly contain queries to your Entity. All you have to do is define your Entity class and `Zfe\Common\Provider\AbstractProvider` does all the heavy lifting

Available methods

```
public function fetchAll(): \Doctrine\ORM\QueryBuilder;

public function selectAll(array $filters = [], array $orderBy = [], array $groupBy = []): \Doctrine\ORM\QueryBuilder;

public function selectAllPaginate(
        $first = 0,
        $max = 20,
        array $filters = [],
        array $orderBy = [],
        array $groupBy = [],
        $fetchJoinCollection = true
    ): Doctrine\ORM\Tools\Pagination\Paginator;

public function selectJoin(
        $first = 0,
        $max = 20,
        array $filters = [],
        array $joins = [],
        array $orderBy = [],
        array $groupBy = []
    ): \Doctrine\ORM\QueryBuilder
```

```
 entity_save_before event fired before an entity is saved
> entity_save_after event fired after an entity is saved
>
> Deleting an Entity
> entity_delete_before event fired before an entity is deleted
> entity_delete_after event fired after an entity is deleted
```

To fire off entity specific event, your provider class must set the value of the `$entity_event_prefix` property. See `PostProvider` definition above. In which case, the following events are now available to us as well:

```
> Saving an Entity
> blog_post_save_before event fired before an entity is saved
> blog_post_save_after event fired after an entity is saved
>
> Deleting an Entity
> blog_post_delete_before event fired before an entity is deleted
> blog_post_delete_after event fired after an entity is deleted
```

To register your own custom event listener, create a `.config.php` file with contents similar to own below:

```
 [
        'events' => [
            // the event we are listening to
            'blog_post_save_before' => [
                'class' => \App\Observer\PostObserver::class, // points to the observer class
                'method' => 'onPostBeforeSaveHandled' // points to the method handling the event
            ]
        ],
    ]
];
```

There is a sample `events.config.php.dist` file included in the `config` folder.

The `App\Observer\PostObserver` defined above could contain the below code. Replace with your logic

```
getName();
        $target = get_class($event->getTarget());
        $entity = $event->getParam('entity');

        /** Modify the Entity */
        if ($entity instanceof \Zfe\Common\Entity\EntityInterface) {
            $entity->setTitle('Title Changed');
        } elseif (is_array($entity)) {
            $entity['title'] = 'Title Changed';
        }

        /** Push changes back to the trigger */
        $event->setParam('entity', $entity);

        $logger = new Logger;
        $logger->addProcessor(new PsrPlaceholder);

        $writer = new Writer\Stream('data/log/events.log');
        $logger->addWriter($writer);

        $logger->notice('{event} was called on {target} with entity {entity}', [
            'event' => $event,
            'target' => $target,
            'entity' => json_encode($entity)
        ]);
    }
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

2940d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2680badf93d6747b9f1f288599e373ba6c6d37f5d5371a9e5e38db51584c202?d=identicon)[awoyotoyin](/maintainers/awoyotoyin)

---

Top Contributors

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

---

Tags

doctrine2eventmanagerzend-expressive3zend-servicemanagerzendzend-expressivezend expressive basezend expressive commonzend expressive abstraction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awoyotoyin-zfe-base/health.svg)

```
[![Health](https://phpackages.com/badges/awoyotoyin-zfe-base/health.svg)](https://phpackages.com/packages/awoyotoyin-zfe-base)
```

###  Alternatives

[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)

PHPackages © 2026

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