PHPackages                             nimayneb/repop - 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. [Database &amp; ORM](/categories/database)
4. /
5. nimayneb/repop

ActiveLibrary[Database &amp; ORM](/categories/database)

nimayneb/repop
==============

Repository Operator - Small Library for CRUD operations with PDO in a model context.

2.0.0(6y ago)04[2 PRs](https://github.com/nimayneb/repop/pulls)GPL-3.0-or-laterPHPPHP ^7.4

Since Apr 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/nimayneb/repop)[ Packagist](https://packagist.org/packages/nimayneb/repop)[ RSS](/packages/nimayneb-repop/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (8)Used By (0)

REPository OPerator
===================

[](#repository-operator)

Connection to database (.env supported)
---------------------------------------

[](#connection-to-database-env-supported)

Prepare with `.env` file:

```
DATABASE_DRIVER=mysql
DATABASE_NAME=test
DATABASE_HOSTNAME=localhost
DATABASE_USERNAME=admin
DATABASE_PASSWORD=secret
DATABASE_PORT=3306

```

Usage in `application.php` (w/ `.env`):

```
$connection = JayBeeR\Repop\Connector\DatabaseFactory::connectToDatabase();

```

Usage in `application.php` (w/o `.env`):

```
$connection = JayBeeR\Repop\Connector\DatabaseFactory::connectToDatabase(
    'mysql',
    'localhost',
    3306,
    'test',
    'admin',
    'secret'
);

```

Register Repository with current connection
-------------------------------------------

[](#register-repository-with-current-connection)

The given class must be extended from abstract JayBeeR\\Repop\\Repository\\RepositoryAttributes.

**Usage:**

```
$connection = JayBeeR\Repop\Connector\DatabaseFactory::connectToDatabase();
$connection->registerRepository({Repository model class}::class);

```

Use Repository with allocated connection
----------------------------------------

[](#use-repository-with-allocated-connection)

**Usage:**

```
$repository = Repository::getRepository('{unique table name for repository}');

```

Create Repository
-----------------

[](#create-repository)

If the name is ambiguous (like singular), use "s", "Container" as a postfix.

**Template:**

```
class {model name in plural} extends JayBeeR\Repop\Repository\RepositoryObject
{
}

```

---

### Set the table name of your repository

[](#set-the-table-name-of-your-repository)

**Usage:**

```
    /**
     * @var string
     */
    protected static $tableName = '{table name}';

```

---

### Specified the properties of a model object

[](#specified-the-properties-of-a-model-object)

**Usage:**

```
    /**
     * @return array
     */
    protected function getTableColumns(): array
    {
        return {static model class}::getTableColumns();
    }

```

---

### Specified the creation of a model object

[](#specified-the-creation-of-a-model-object)

**Usage:**

```
    /**
     * @param PDOStatement $statement
     *
     * @return {model class}
     */
    protected function toObject(PDOStatement $statement): {model class}
    {
        return {static model class}::fromResult($statement);
    }

```

---

### Define a public method for a query

[](#define-a-public-method-for-a-query)

**Conventions:**

- say what you want to find: "findElementWithLove" =&gt; returns PDOStatement (reusable)
- say what you want to get: "elementWithLove" =&gt; returns Generator (not reusable, usage with `foreach`)

**Usage (as Generator):**

```
    /**
     * @return Generator
     */
    public function elementWithLove(string $value): Generator
    {
        $statement = $this->getConnection()->prepare(
            "select {$this->buildTableColumnsStatement()}
                from `{$this->getTable()}`
                    where `column_name` = :columnName;"
        );

        $statement->bindParam(':columnName', $value, PDO::PARAM_STR);

        $this->ensureStatementExecution($statement);

        return $this->iterate($statement);
    }

```

**Usage (reusable):**

```
    /**
     * @return PDOStatement
     */
    public function elementWithLove(string $value): PDOStatement
    {
        $statement = $this->getConnection()->prepare(
            "select {$this->buildTableColumnsStatement()}
                from `{$this->getTable()}`
                    where `column_name` = :columnName;"
        );

        $statement->bindParam(':columnName', $value, PDO::PARAM_STR);

        $this->ensureStatementExecution($statement);

        return $statement;
    }

```

Create Model class
------------------

[](#create-model-class)

If the name is ambiguous (like plural), use "Single", "Item", "Piece" as a postfix.

**Template:**

```
class {model name in singular} extends JayBeeR\Repop\Model\ModelObject
{
}

```

---

### Add new column property

[](#add-new-column-property)

**Conventions:**

- use underscores (like SQL)
    - RIGHT: `$column_name;`
    - WRONG: `$columnName;`
- must be protected properties

**Possible types:**

- string
- float
- int
- bool

**Usage:**

```
    /**
     * {Description}
     */
    protected {column type} ${column name};

```

---

### Add Getter method for column property

[](#add-getter-method-for-column-property)

**Conventions:**

- use camel case and more understandable name of your column
    - not "getUid" =&gt; "getIdentifier"
    - not "getTxExtensionLock" =&gt; "getLockState"

**Possible types:**

- string
- float
- int
- bool

**Usage:**

```
    /**
     * @return {column type}
     */
    public function get{colum name}(): {column type}
    {
        return $this->{colum name};
    }

```

---

### Add Setter method for column property

[](#add-setter-method-for-column-property)

**Conventions:**

- use camel case and more understandable name of your column
    - not "setUid" =&gt; "setIdentifier"
    - not "setTxExtensionLock" =&gt; "setLockState"

**Usage:**

```
    /**
     * @param {column type} $value
     */
    public function set{column name}({column type} $value): void
    {
        $this->updateColumnValue(static::{column name}, $value);
    }

```

---

### Add static method to create this model class by PDOStatement

[](#add-static-method-to-create-this-model-class-by-pdostatement)

**Usage:**

```
    /**
     * @param PDOStatement $statement
     *
     * @return {ModelClass}|null
     */
    public static function fromResult(PDOStatement $statement): ?{ModelClass}
    {
        return static::get($statement);
    }

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~2 days

Total

4

Last Release

2222d ago

Major Versions

1.2.0 → 2.0.02020-04-15

PHP version history (2 changes)1.0.0PHP ^7.2

2.0.0PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fbcb5c834ad511bbf12b303f38026f1c00466d4e2fe1e96f5bcfbae83779ac9?d=identicon)[nimayneb](/maintainers/nimayneb)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![nimayneb](https://avatars.githubusercontent.com/u/9550921?v=4)](https://github.com/nimayneb "nimayneb (1 commits)")

---

Tags

databasepdomodelcrudrepository

### Embed Badge

![Health badge](/badges/nimayneb-repop/health.svg)

```
[![Health](https://phpackages.com/badges/nimayneb-repop/health.svg)](https://phpackages.com/packages/nimayneb-repop)
```

###  Alternatives

[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86946.7k](/packages/ezsql-ezsql)[kajalpandya/generate_laravel_crud

Run command in terminal and make ready made crud for your entity

151.5k](/packages/kajalpandya-generate-laravel-crud)

PHPackages © 2026

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